< prev index next >

test/jdk/java/util/concurrent/tck/DelayQueueTest.java

Print this page
8207003: Miscellaneous changes imported from jsr166 CVS 2018-09
Reviewed-by: martin, chegar


  79     }
  80 
  81     /**
  82      * A fake Delayed implementation for testing.
  83      * Most tests use PDelays, where delays are all elapsed
  84      * (so, no blocking solely for delays) but are still ordered
  85      */
  86     static class PDelay implements Delayed {
  87         final int pseudodelay;
  88         PDelay(int pseudodelay) { this.pseudodelay = pseudodelay; }
  89         public int compareTo(Delayed y) {
  90             return Integer.compare(this.pseudodelay, ((PDelay)y).pseudodelay);
  91         }
  92         public boolean equals(Object other) {
  93             return (other instanceof PDelay) &&
  94                 this.pseudodelay == ((PDelay)other).pseudodelay;
  95         }
  96         // suppress [overrides] javac warning
  97         public int hashCode() { return pseudodelay; }
  98         public long getDelay(TimeUnit ignore) {
  99             return Integer.MIN_VALUE + pseudodelay;
 100         }
 101         public String toString() {
 102             return String.valueOf(pseudodelay);
 103         }
 104     }
 105 
 106     /**
 107      * Delayed implementation that actually delays
 108      */
 109     static class NanoDelay implements Delayed {
 110         final long trigger;
 111         NanoDelay(long i) {
 112             trigger = System.nanoTime() + i;
 113         }
 114 
 115         public int compareTo(Delayed y) {
 116             return Long.compare(trigger, ((NanoDelay)y).trigger);
 117         }
 118 
 119         public boolean equals(Object other) {




  79     }
  80 
  81     /**
  82      * A fake Delayed implementation for testing.
  83      * Most tests use PDelays, where delays are all elapsed
  84      * (so, no blocking solely for delays) but are still ordered
  85      */
  86     static class PDelay implements Delayed {
  87         final int pseudodelay;
  88         PDelay(int pseudodelay) { this.pseudodelay = pseudodelay; }
  89         public int compareTo(Delayed y) {
  90             return Integer.compare(this.pseudodelay, ((PDelay)y).pseudodelay);
  91         }
  92         public boolean equals(Object other) {
  93             return (other instanceof PDelay) &&
  94                 this.pseudodelay == ((PDelay)other).pseudodelay;
  95         }
  96         // suppress [overrides] javac warning
  97         public int hashCode() { return pseudodelay; }
  98         public long getDelay(TimeUnit ignore) {
  99             return (long) Integer.MIN_VALUE + pseudodelay;
 100         }
 101         public String toString() {
 102             return String.valueOf(pseudodelay);
 103         }
 104     }
 105 
 106     /**
 107      * Delayed implementation that actually delays
 108      */
 109     static class NanoDelay implements Delayed {
 110         final long trigger;
 111         NanoDelay(long i) {
 112             trigger = System.nanoTime() + i;
 113         }
 114 
 115         public int compareTo(Delayed y) {
 116             return Long.compare(trigger, ((NanoDelay)y).trigger);
 117         }
 118 
 119         public boolean equals(Object other) {


< prev index next >