235 |
|
/** |
236 |
|
* Marks completion and wakes up threads waiting to join this |
237 |
|
* task, also clearing signal request bits. A specialization for |
238 |
< |
* NORMAL completion is in method doExec |
238 |
> |
* NORMAL completion is in method doExec. |
239 |
|
* |
240 |
|
* @param completion one of NORMAL, CANCELLED, EXCEPTIONAL |
241 |
|
* @return completion status on exit |
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 |
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 |
|
/** |
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 |
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 |