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 |
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 |
|
/** |
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 |
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 |