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

Comparing jsr166/src/main/java/util/concurrent/FutureTask.java (file contents):
Revision 1.34 by jsr166, Mon May 2 08:40:27 2005 UTC vs.
Revision 1.35 by jsr166, Mon May 2 18:38:53 2005 UTC

# Line 66 | Line 66 | public class FutureTask<V> implements Fu
66      public boolean isCancelled() {
67          return sync.innerIsCancelled();
68      }
69 <    
69 >
70      public boolean isDone() {
71          return sync.innerIsDone();
72      }
# Line 74 | Line 74 | public class FutureTask<V> implements Fu
74      public boolean cancel(boolean mayInterruptIfRunning) {
75          return sync.innerCancel(mayInterruptIfRunning);
76      }
77 <    
77 >
78      public V get() throws InterruptedException, ExecutionException {
79          return sync.innerGet();
80      }
# Line 99 | Line 99 | public class FutureTask<V> implements Fu
99       * Sets the result of this Future to the given value unless
100       * this future has already been set or has been cancelled.
101       * @param v the value
102 <     */
102 >     */
103      protected void set(V v) {
104          sync.innerSet(v);
105      }
# Line 109 | Line 109 | public class FutureTask<V> implements Fu
109       * with the given throwable as its cause, unless this Future has
110       * already been set or has been cancelled.
111       * @param t the cause of failure.
112 <     */
112 >     */
113      protected void setException(Throwable t) {
114          sync.innerSetException(t);
115      }
116 <    
116 >
117      /**
118       * Sets this Future to the result of computation unless
119       * it has been cancelled.
# Line 157 | Line 157 | public class FutureTask<V> implements Fu
157          /** The exception to throw from get() */
158          private Throwable exception;
159  
160 <        /**
160 >        /**
161           * The thread running task. When nulled after set/cancel, this
162           * indicates that the results are accessible.  Must be
163           * volatile, to ensure visibility upon completion.
# Line 185 | Line 185 | public class FutureTask<V> implements Fu
185           */
186          protected boolean tryReleaseShared(int ignore) {
187              runner = null;
188 <            return true;
188 >            return true;
189          }
190  
191          boolean innerIsCancelled() {
192              return getState() == CANCELLED;
193          }
194 <        
194 >
195          boolean innerIsDone() {
196              return ranOrCancelled(getState()) && runner == null;
197          }
# Line 207 | Line 207 | public class FutureTask<V> implements Fu
207  
208          V innerGet(long nanosTimeout) throws InterruptedException, ExecutionException, TimeoutException {
209              if (!tryAcquireSharedNanos(0, nanosTimeout))
210 <                throw new TimeoutException();                
210 >                throw new TimeoutException();
211              if (getState() == CANCELLED)
212                  throw new CancellationException();
213              if (exception != null)
# Line 247 | Line 247 | public class FutureTask<V> implements Fu
247                  int s = getState();
248                  if (ranOrCancelled(s))
249                      return false;
250 <                if (compareAndSetState(s, CANCELLED))
250 >                if (compareAndSetState(s, CANCELLED))
251                      break;
252              }
253              if (mayInterruptIfRunning) {
# Line 261 | Line 261 | public class FutureTask<V> implements Fu
261          }
262  
263          void innerRun() {
264 <            if (!compareAndSetState(0, RUNNING))
264 >            if (!compareAndSetState(0, RUNNING))
265                  return;
266              try {
267                  runner = Thread.currentThread();
268                  innerSet(callable.call());
269              } catch (Throwable ex) {
270                  innerSetException(ex);
271 <            }
271 >            }
272          }
273  
274          boolean innerRunAndReset() {
275 <            if (!compareAndSetState(0, RUNNING))
275 >            if (!compareAndSetState(0, RUNNING))
276                  return false;
277              try {
278                  runner = Thread.currentThread();
# Line 282 | Line 282 | public class FutureTask<V> implements Fu
282              } catch (Throwable ex) {
283                  innerSetException(ex);
284                  return false;
285 <            }
285 >            }
286          }
287      }
288   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines