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

Comparing jsr166/src/main/java/util/concurrent/CancellableTask.java (file contents):
Revision 1.21 by dl, Sun Oct 12 21:05:28 2003 UTC vs.
Revision 1.22 by jozart, Wed Nov 26 06:25:34 2003 UTC

# Line 5 | Line 5
5   */
6  
7   package java.util.concurrent;
8 +
9   import java.util.concurrent.atomic.*;
10   import java.util.concurrent.locks.*;
11  
# Line 17 | Line 18 | import java.util.concurrent.locks.*;
18   * @since 1.5
19   * @author Doug Lea
20   */
20
21   public class CancellableTask implements Cancellable, Runnable {
22      /**
23       * Holds the run-state, taking on values:
# Line 40 | Line 40 | public class CancellableTask implements
40      private static final Object CANCELLED = new Object();
41  
42      private static AtomicReferenceFieldUpdater<CancellableTask, Object>
43 <        runnerUpdater =
44 <        AtomicReferenceFieldUpdater.newUpdater
45 <        (CancellableTask.class, Object.class, "runner");
43 >        runnerUpdater =
44 >            AtomicReferenceFieldUpdater.newUpdater(
45 >                CancellableTask.class,
46 >                Object.class,
47 >                "runner");
48  
49      /**
50       * The runnable underlying this task
# Line 70 | Line 72 | public class CancellableTask implements
72      protected CancellableTask() {
73      }
74  
73
75      public boolean cancel(boolean mayInterruptIfRunning) {
76          Object r = runner;
77          if (r == DONE || r == CANCELLED)
# Line 99 | Line 100 | public class CancellableTask implements
100      }
101  
102      /**
103 <     * Return the Runnable forming the basis of this task.
103 >     * Returns the Runnable forming the basis of this task.
104       * @return the runnable action
105       * @see #setRunnable
106       */
# Line 108 | Line 109 | public class CancellableTask implements
109      }
110  
111      /**
112 <     * Set the Runnable forming the basis of this task.
112 >     * Sets the Runnable forming the basis of this task.
113       * @param r the runnable action
114       * @see #getRunnable
115       */
# Line 117 | Line 118 | public class CancellableTask implements
118      }
119  
120      /**
121 <     * Set the state of this task to Cancelled.
121 >     * Sets the state of this task to Cancelled.
122       */
123      protected void setCancelled() {
124          runnerUpdater.set(this, CANCELLED);
125      }
126      
127      /**
128 <     * Set the state of this task to Done, unless already
129 <     * in a Cancelled state, in which Cancelled status is preserved.
129 <     *
128 >     * Sets the state of this task to Done, unless already in a
129 >     * Cancelled state, in which case Cancelled status is preserved.
130       */
131      protected void setDone() {
132          for (;;) {
# Line 141 | Line 141 | public class CancellableTask implements
141      }
142  
143      /**
144 <     * Attempt to set the state of this task to Running, succeeding
144 >     * Attempts to set the state of this task to Running, succeeding
145       * only if the state is currently NOT Done, Running, or Cancelled.
146       * @return true if successful
147       */
# Line 174 | Line 174 | public class CancellableTask implements
174      protected void done() { }
175  
176      /**
177 <     * Reset the run state of this task to its initial state unless
177 >     * Resets the run state of this task to its initial state unless
178       * it has been cancelled. (Note that a cancelled task cannot be
179       * reset.)
180       * @return true if successful
# Line 230 | Line 230 | public class CancellableTask implements
230          private Throwable exception;
231  
232          /**
233 <         * Create an InnerCancellableFuture that will execute the
233 >         * Creates an InnerCancellableFuture that will execute the
234           * given callable.
235           * @param callable the function to execute
236           */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines