ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ScheduledExecutor.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ScheduledExecutor.java (file contents):
Revision 1.11 by tim, Wed Aug 6 18:22:09 2003 UTC vs.
Revision 1.12 by dl, Thu Aug 7 16:00:28 2003 UTC

# Line 85 | Line 85 | public class ScheduledExecutor extends T
85  
86  
87          public long getDelay(TimeUnit unit) {
88 <            return unit.convert(time - System.nanoTime(),
88 >            long d =  unit.convert(time - System.nanoTime(),
89                                  TimeUnit.NANOSECONDS);
90 +            return d;
91          }
92  
93          public int compareTo(Object other) {
# Line 179 | Line 180 | public class ScheduledExecutor extends T
180       * An annoying wrapper class to convince generics compiler to
181       * use a DelayQueue<DelayedTask> as a BlockingQueue<Runnable>
182       */
183 <    private static class DelayedWorkQueue extends AbstractQueue<Runnable> implements BlockingQueue<Runnable> {
183 >    private static class DelayedWorkQueue extends AbstractCollection<Runnable> implements BlockingQueue<Runnable> {
184          private final DelayQueue<DelayedTask> dq = new DelayQueue<DelayedTask>();
185          public Runnable poll() { return dq.poll(); }
186          public Runnable peek() { return dq.peek(); }
# Line 187 | Line 188 | public class ScheduledExecutor extends T
188          public Runnable poll(long timeout, TimeUnit unit) throws InterruptedException {
189              return dq.poll(timeout, unit);
190          }
191 +
192 +        public boolean add(Runnable x) { return dq.add((DelayedTask)x); }
193          public boolean offer(Runnable x) { return dq.offer((DelayedTask)x); }
194          public void put(Runnable x) throws InterruptedException {
195              dq.put((DelayedTask)x);
# Line 194 | Line 197 | public class ScheduledExecutor extends T
197          public boolean offer(Runnable x, long timeout, TimeUnit unit) throws InterruptedException {
198              return dq.offer((DelayedTask)x, timeout, unit);
199          }
200 +
201 +        public Runnable remove() { return dq.remove(); }
202 +        public Runnable element() { return dq.element(); }
203 +        public void clear() { dq.clear(); }
204 +
205          public int remainingCapacity() { return dq.remainingCapacity(); }
206          public boolean remove(Object x) { return dq.remove(x); }
207          public boolean contains(Object x) { return dq.contains(x); }
# Line 218 | Line 226 | public class ScheduledExecutor extends T
226      public ScheduledExecutor(int corePoolSize) {
227          super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS,
228                new DelayedWorkQueue());
229 +        prestartCoreThreads();
230      }
231  
232      /**
# Line 232 | Line 241 | public class ScheduledExecutor extends T
241                               ThreadFactory threadFactory) {
242          super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS,
243                new DelayedWorkQueue(), threadFactory);
244 +        prestartCoreThreads();
245      }
246  
247      /**
# Line 246 | Line 256 | public class ScheduledExecutor extends T
256                                RejectedExecutionHandler handler) {
257          super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS,
258                new DelayedWorkQueue(), handler);
259 +        prestartCoreThreads();
260      }
261  
262      /**
# Line 263 | Line 274 | public class ScheduledExecutor extends T
274                                RejectedExecutionHandler handler) {
275          super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS,
276                new DelayedWorkQueue(), threadFactory, handler);
277 +        prestartCoreThreads();
278      }
279  
280      /**
# Line 452 | Line 464 | public class ScheduledExecutor extends T
464          if (next == null)
465              return;
466          try {
467 <            super.execute(next);
467 >            execute(next);
468          }
469          catch(RejectedExecutionException ex) {
470              // lost race to detect shutdown; ignore

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines