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.4 by dl, Tue Jun 3 16:44:36 2003 UTC vs.
Revision 1.5 by dl, Wed Jun 4 11:34:20 2003 UTC

# Line 25 | Line 25 | import java.util.*;
25   public class ScheduledExecutor extends ThreadPoolExecutor {
26  
27      /**
28 <     * A delayed or periodic action.
28 >     * Sequence number to break scheduling ties, and in turn to
29 >     * guarantee FIFO order among tied entries.
30       */
31 <    public static class DelayedTask extends CancellableTask implements Delayed {
31 <        /**
32 <         * Sequence number to break ties, and in turn to guarantee
33 <         * FIFO order among tied entries.
34 <         */
35 <        private static final AtomicLong sequencer = new AtomicLong(0);
31 >    private static final AtomicLong sequencer = new AtomicLong(0);
32  
33 +    /**
34 +     * A delayed or periodic action.
35 +     */
36 +    public class DelayedTask extends CancellableTask implements Delayed {
37          private final long sequenceNumber;
38          private final long time;
39          private final long period;
40  
41          /**
42 <         * Creates a one-shot action with given nanosecond delay
42 >         * Creates a one-shot action with given nanoTime-based trigger time
43           */
44          DelayedTask(Runnable r, long ns) {
45              super(r);
# Line 49 | Line 49 | public class ScheduledExecutor extends T
49          }
50  
51          /**
52 <         * Creates a periodic action with given nanosecond delay and period
52 >         * Creates a periodic action with given nano time and period
53           */
54          DelayedTask(Runnable r, long ns,  long period) {
55              super(r);
# Line 78 | Line 78 | public class ScheduledExecutor extends T
78                  return 1;
79          }
80  
81 +        public boolean cancel(boolean mayInterruptIfRunning) {
82 +            if (!isDone())
83 +                ScheduledExecutor.this.remove(this);
84 +            return super.cancel(mayInterruptIfRunning);
85 +        }
86 +
87          /**
88           * Return true if this is a periodic (not a one-shot) action.
89           */
# Line 97 | Line 103 | public class ScheduledExecutor extends T
103           * subsequent to current task, or null if non-periodic
104           * or canceled.
105           */
106 <        public  DelayedTask nextTask() {
106 >        DelayedTask nextTask() {
107              if (period <= 0 || isCancelled())
108                  return null;
109              return new DelayedTask(getRunnable(), time+period, period);
# Line 108 | Line 114 | public class ScheduledExecutor extends T
114      /**
115       * A delayed result-bearing action.
116       */
117 <    public static class DelayedFutureTask<V> extends DelayedTask implements Future<V> {
117 >    public class DelayedFutureTask<V> extends DelayedTask implements Future<V> {
118          /**
119           * Creates a Future that may trigger after the given delay.
120           */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines