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

Comparing jsr166/src/jsr166y/ForkJoinTask.java (file contents):
Revision 1.81 by dl, Thu Jan 26 00:08:13 2012 UTC vs.
Revision 1.82 by dl, Thu Jan 26 18:15:12 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines