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.20 by dl, Sat Oct 11 15:37:31 2003 UTC vs.
Revision 1.21 by dl, Sun Oct 12 21:05:28 2003 UTC

# Line 84 | Line 84 | public class CancellableTask implements
84              ((Thread)r).interrupt();
85          else
86              runnerUpdater.set(this, CANCELLED);
87 +
88 +        done();
89          return true;
90      }
91      
# Line 131 | Line 133 | public class CancellableTask implements
133              Object r = runner;
134              if (r == DONE || r == CANCELLED)
135                  return;
136 <            if (runnerUpdater.compareAndSet(this, r, DONE))
136 >            if (runnerUpdater.compareAndSet(this, r, DONE)) {
137 >                done();
138                  return;
139 +            }
140          }
141      }
142  
# Line 159 | Line 163 | public class CancellableTask implements
163      }
164  
165      /**
166 +     * Protected method invoked when this task transitions to state
167 +     * <tt>isDone</tt> (whether normally or via cancellation). The
168 +     * default implementation does nothing.  Subclasses may override
169 +     * this method to invoke completion callbacks or perform
170 +     * bookkeeping. Note that you can query status inside the
171 +     * implementation of this method to determine whether this task
172 +     * has been cancelled.
173 +     */
174 +    protected void done() { }
175 +
176 +    /**
177       * Reset 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.)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines