492 |
|
* terminate others by cancelling their unprocessed tasks, and |
493 |
|
* waking them up. Calls to non-abrupt shutdown() preface this by |
494 |
|
* checking isQuiescent before triggering the "STOP" phase of |
495 |
< |
* termination. |
495 |
> |
* termination. To conform to ExecutorService invoke, invokeAll, |
496 |
> |
* and invokeAny specs, we must track pool status while waiting, |
497 |
> |
* and interrupt interruptable callers on termination (see |
498 |
> |
* ForkJoinTask.joinForPoolInvoke etc). |
499 |
|
* |
500 |
|
* Joining Tasks |
501 |
|
* ============= |
605 |
|
* amounts to an odd form of limited spin-wait before blocking in |
606 |
|
* ForkJoinTask.join. |
607 |
|
* |
608 |
+ |
* Guarantees for common pool parallelism zero are limited to |
609 |
+ |
* tasks that are joined by their callers in a tree-structured |
610 |
+ |
* fashion or use CountedCompleters (as is true for jdk |
611 |
+ |
* parallelStreams). Support infiltrates several methods, |
612 |
+ |
* including those that retry helping steps until we are sure that |
613 |
+ |
* none apply if there are no workers. |
614 |
+ |
* |
615 |
|
* As a more appropriate default in managed environments, unless |
616 |
|
* overridden by system properties, we use workers of subclass |
617 |
|
* InnocuousForkJoinWorkerThread when there is a SecurityManager |
2123 |
|
lock.unlock(); |
2124 |
|
} |
2125 |
|
} |
2126 |
< |
else if (q.tryLock()) |
2117 |
< |
return q; |
2118 |
< |
else if ((md & SMASK) != 0) // move unless no parallelism |
2126 |
> |
else if (!q.tryLock()) // move and restart |
2127 |
|
id = (r = ThreadLocalRandom.advanceProbe(r)) << 1; |
2128 |
+ |
else |
2129 |
+ |
return q; |
2130 |
|
} |
2131 |
|
} |
2132 |
|
|