937 |
|
// currentJoin only written by this thread; only need ordered store |
938 |
|
ForkJoinTask<?> prevJoin = currentJoin; |
939 |
|
UNSAFE.putOrderedObject(this, currentJoinOffset, joinMe); |
940 |
< |
if (sp != base) |
941 |
< |
localHelpJoinTask(joinMe); |
942 |
< |
if (joinMe.status >= 0) |
943 |
< |
pool.awaitJoin(joinMe, this); |
940 |
> |
if (isTerminating()) // cancel if shutting down |
941 |
> |
joinMe.cancelIgnoringExceptions(); |
942 |
> |
else { |
943 |
> |
if (sp != base) |
944 |
> |
localHelpJoinTask(joinMe); |
945 |
> |
if (joinMe.status >= 0) |
946 |
> |
pool.awaitJoin(joinMe, this); |
947 |
> |
} |
948 |
|
UNSAFE.putOrderedObject(this, currentJoinOffset, prevJoin); |
949 |
|
} |
950 |
|
|
982 |
|
} |
983 |
|
|
984 |
|
/** |
985 |
< |
* Unless terminating, tries to locate and help perform tasks for |
986 |
< |
* a stealer of the given task, or in turn one of its stealers. |
987 |
< |
* Traces currentSteal->currentJoin links looking for a thread |
988 |
< |
* working on a descendant of the given task and with a non-empty |
989 |
< |
* queue to steal back and execute tasks from. |
985 |
> |
* Tries to locate and help perform tasks for a stealer of the |
986 |
> |
* given task, or in turn one of its stealers. Traces |
987 |
> |
* currentSteal->currentJoin links looking for a thread working on |
988 |
> |
* a descendant of the given task and with a non-empty queue to |
989 |
> |
* steal back and execute tasks from. |
990 |
|
* |
991 |
|
* The implementation is very branchy to cope with potential |
992 |
|
* inconsistencies or loops encountering chains that are stale, |
1002 |
|
int n; |
1003 |
|
if (joinMe.status < 0) // already done |
1004 |
|
return; |
1001 |
– |
if ((runState & TERMINATING) != 0) { // cancel if shutting down |
1002 |
– |
joinMe.cancelIgnoringExceptions(); |
1003 |
– |
return; |
1004 |
– |
} |
1005 |
|
if ((ws = pool.workers) == null || (n = ws.length) <= 1) |
1006 |
|
return; // need at least 2 workers |
1007 |
|
|