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

Comparing jsr166/src/main/java/util/concurrent/ForkJoinTask.java (file contents):
Revision 1.54 by dl, Thu Jan 26 00:08:17 2012 UTC vs.
Revision 1.55 by dl, Thu Jan 26 18:15:16 2012 UTC

# Line 396 | Line 396 | public abstract class ForkJoinTask<V> im
396       * @return status upon completion
397       */
398      private int doInvoke() {
399 <        int s;
400 <        if ((s = doExec()) < 0)
401 <            return s;
402 <        else
403 <            return doJoin();
399 >        int s; Thread t;
400 >        if ((s = doExec()) >= 0) {
401 >            if (!((t = Thread.currentThread()) instanceof ForkJoinWorkerThread))
402 >                s = externalAwaitDone();
403 >            else {
404 >                ForkJoinWorkerThread wt = (ForkJoinWorkerThread)t;
405 >                s = awaitJoin(wt.workQueue, wt.pool);
406 >            }
407 >        }
408 >        return s;
409      }
410  
411      // Exception table support
# Line 1071 | Line 1076 | public abstract class ForkJoinTask<V> im
1076       * ClassCastException}.
1077       */
1078      public static void helpQuiesce() {
1079 <        ForkJoinWorkerThread w =
1079 >        ForkJoinWorkerThread wt =
1080              (ForkJoinWorkerThread)Thread.currentThread();
1081 <        w.pool.helpQuiescePool(w.workQueue);
1081 >        wt.pool.helpQuiescePool(wt.workQueue);
1082      }
1083  
1084      /**
# Line 1226 | Line 1231 | public abstract class ForkJoinTask<V> im
1231           * have zero queued tasks, so compensate by a factor of
1232           * (#idle/#active) threads.
1233           */
1234 <        ForkJoinWorkerThread w =
1234 >        ForkJoinWorkerThread wt =
1235              (ForkJoinWorkerThread)Thread.currentThread();
1236 <        return w.workQueue.queueSize() - w.pool.idlePerActive();
1236 >        return wt.workQueue.queueSize() - wt.pool.idlePerActive();
1237      }
1238  
1239      // Extension methods
# Line 1326 | Line 1331 | public abstract class ForkJoinTask<V> im
1331       * @return a task, or {@code null} if none are available
1332       */
1333      protected static ForkJoinTask<?> pollTask() {
1334 <        ForkJoinWorkerThread w =
1334 >        ForkJoinWorkerThread wt =
1335              (ForkJoinWorkerThread)Thread.currentThread();
1336 <        return w.pool.nextTaskFor(w.workQueue);
1336 >        return wt.pool.nextTaskFor(wt.workQueue);
1337      }
1338  
1339      // Mark-bit operations

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines