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.55 by jsr166, Wed Aug 8 16:19:04 2007 UTC vs.
Revision 1.56 by jsr166, Sun May 18 23:47:56 2008 UTC

# Line 217 | Line 217 | public class FutureTask<V> implements Ru
217  
218          V innerGet() throws InterruptedException, ExecutionException {
219              acquireSharedInterruptibly(0);
220 <            if (getState() == CANCELLED)
221 <                throw new CancellationException();
222 <            if (exception != null)
223 <                throw new ExecutionException(exception);
224 <            return result;
220 >            if (getState() == CANCELLED)
221 >                throw new CancellationException();
222 >            if (exception != null)
223 >                throw new ExecutionException(exception);
224 >            return result;
225          }
226  
227          V innerGet(long nanosTimeout) throws InterruptedException, ExecutionException, TimeoutException {
# Line 235 | Line 235 | public class FutureTask<V> implements Ru
235          }
236  
237          void innerSet(V v) {
238 <            for (;;) {
239 <                int s = getState();
240 <                if (s == RAN)
241 <                    return;
238 >            for (;;) {
239 >                int s = getState();
240 >                if (s == RAN)
241 >                    return;
242                  if (s == CANCELLED) {
243 <                    // aggressively release to set runner to null,
244 <                    // in case we are racing with a cancel request
245 <                    // that will try to interrupt runner
243 >                    // aggressively release to set runner to null,
244 >                    // in case we are racing with a cancel request
245 >                    // that will try to interrupt runner
246                      releaseShared(0);
247                      return;
248                  }
249 <                if (compareAndSetState(s, RAN)) {
249 >                if (compareAndSetState(s, RAN)) {
250                      result = v;
251                      releaseShared(0);
252                      done();
253 <                    return;
253 >                    return;
254                  }
255              }
256          }
257  
258          void innerSetException(Throwable t) {
259 <            for (;;) {
260 <                int s = getState();
261 <                if (s == RAN)
262 <                    return;
259 >            for (;;) {
260 >                int s = getState();
261 >                if (s == RAN)
262 >                    return;
263                  if (s == CANCELLED) {
264 <                    // aggressively release to set runner to null,
265 <                    // in case we are racing with a cancel request
266 <                    // that will try to interrupt runner
264 >                    // aggressively release to set runner to null,
265 >                    // in case we are racing with a cancel request
266 >                    // that will try to interrupt runner
267                      releaseShared(0);
268                      return;
269                  }
270 <                if (compareAndSetState(s, RAN)) {
270 >                if (compareAndSetState(s, RAN)) {
271                      exception = t;
272                      releaseShared(0);
273                      done();
274 <                    return;
274 >                    return;
275                  }
276 <            }
276 >            }
277          }
278  
279          boolean innerCancel(boolean mayInterruptIfRunning) {
280 <            for (;;) {
281 <                int s = getState();
282 <                if (ranOrCancelled(s))
283 <                    return false;
284 <                if (compareAndSetState(s, CANCELLED))
285 <                    break;
286 <            }
280 >            for (;;) {
281 >                int s = getState();
282 >                if (ranOrCancelled(s))
283 >                    return false;
284 >                if (compareAndSetState(s, CANCELLED))
285 >                    break;
286 >            }
287              if (mayInterruptIfRunning) {
288                  Thread r = runner;
289                  if (r != null)
# Line 310 | Line 310 | public class FutureTask<V> implements Ru
310                  set(result);
311              } else {
312                  releaseShared(0); // cancel
313 <            }
313 >            }
314          }
315  
316          boolean innerRunAndReset() {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines