home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / sun / misc / GC$LatencyRequest.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.3 KB  |  91 lines

  1. package sun.misc;
  2.  
  3. import java.util.SortedSet;
  4. import java.util.TreeSet;
  5.  
  6. public class GC$LatencyRequest implements Comparable {
  7.    private static long counter = 0L;
  8.    private static SortedSet requests = null;
  9.    private long latency;
  10.    // $FF: renamed from: id long
  11.    private long field_0;
  12.    // $FF: synthetic field
  13.    static Class class$sun$misc$GC$LatencyRequest;
  14.  
  15.    private static void adjustLatencyIfNeeded() {
  16.       if (requests != null && !requests.isEmpty()) {
  17.          GC$LatencyRequest var0 = (GC$LatencyRequest)requests.first();
  18.          if (var0.latency != GC.access$200()) {
  19.             GC.access$500(var0.latency);
  20.          }
  21.       } else if (GC.access$200() != Long.MAX_VALUE) {
  22.          GC.access$500(Long.MAX_VALUE);
  23.       }
  24.  
  25.    }
  26.  
  27.    private GC$LatencyRequest(long var1) {
  28.       if (var1 <= 0L) {
  29.          throw new IllegalArgumentException("Non-positive latency: " + var1);
  30.       } else {
  31.          this.latency = var1;
  32.          Object var3 = GC.access$100();
  33.          synchronized(var3) {
  34.             this.field_0 = ++counter;
  35.             if (requests == null) {
  36.                requests = new TreeSet();
  37.             }
  38.  
  39.             requests.add(this);
  40.             adjustLatencyIfNeeded();
  41.          }
  42.       }
  43.    }
  44.  
  45.    public void cancel() {
  46.       Object var1 = GC.access$100();
  47.       synchronized(var1) {
  48.          if (this.latency == Long.MAX_VALUE) {
  49.             throw new IllegalStateException("Request already cancelled");
  50.          } else if (!requests.remove(this)) {
  51.             throw new InternalError("Latency request " + this + " not found");
  52.          } else {
  53.             if (requests.isEmpty()) {
  54.                requests = null;
  55.             }
  56.  
  57.             this.latency = Long.MAX_VALUE;
  58.             adjustLatencyIfNeeded();
  59.          }
  60.       }
  61.    }
  62.  
  63.    public int compareTo(Object var1) {
  64.       GC$LatencyRequest var2 = (GC$LatencyRequest)var1;
  65.       long var3 = this.latency - var2.latency;
  66.       if (var3 == 0L) {
  67.          var3 = this.field_0 - var2.field_0;
  68.       }
  69.  
  70.       return var3 < 0L ? -1 : (var3 > 0L ? 1 : 0);
  71.    }
  72.  
  73.    public String toString() {
  74.       return (class$sun$misc$GC$LatencyRequest == null ? (class$sun$misc$GC$LatencyRequest = class$("sun.misc.GC$LatencyRequest")) : class$sun$misc$GC$LatencyRequest).getName() + "[" + this.latency + "," + this.field_0 + "]";
  75.    }
  76.  
  77.    // $FF: synthetic method
  78.    static Class class$(String var0) {
  79.       try {
  80.          return Class.forName(var0);
  81.       } catch (ClassNotFoundException var2) {
  82.          throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  83.       }
  84.    }
  85.  
  86.    // $FF: synthetic method
  87.    GC$LatencyRequest(long var1, GC.1 var3) {
  88.       this(var1);
  89.    }
  90. }
  91.