762 |
|
|
763 |
|
/** |
764 |
|
* Tries to enqueue worker w in wait queue and await change in |
765 |
< |
* worker's eventCount. If the pool is quiescent, possibly |
766 |
< |
* terminates worker upon exit. Otherwise, before blocking, |
767 |
< |
* rescans queues to avoid missed signals. Upon finding work, |
768 |
< |
* releases at least one worker (which may be the current |
769 |
< |
* worker). Rescans restart upon detected staleness or failure to |
770 |
< |
* release due to contention. Note the unusual conventions about |
771 |
< |
* Thread.interrupt here and elsewhere: Because interrupts are |
772 |
< |
* used solely to alert threads to check termination, which is |
773 |
< |
* checked here anyway, we clear status (using Thread.interrupted) |
774 |
< |
* before any call to park, so that park does not immediately |
775 |
< |
* return due to status being set via some other unrelated call to |
776 |
< |
* interrupt in user code. |
765 |
> |
* worker's eventCount. If the pool is quiescent and there is |
766 |
> |
* more than one worker, possibly terminates worker upon exit. |
767 |
> |
* Otherwise, before blocking, rescans queues to avoid missed |
768 |
> |
* signals. Upon finding work, releases at least one worker |
769 |
> |
* (which may be the current worker). Rescans restart upon |
770 |
> |
* detected staleness or failure to release due to |
771 |
> |
* contention. Note the unusual conventions about Thread.interrupt |
772 |
> |
* here and elsewhere: Because interrupts are used solely to alert |
773 |
> |
* threads to check termination, which is checked here anyway, we |
774 |
> |
* clear status (using Thread.interrupted) before any call to |
775 |
> |
* park, so that park does not immediately return due to status |
776 |
> |
* being set via some other unrelated call to interrupt in user |
777 |
> |
* code. |
778 |
|
* |
779 |
|
* @param w the calling worker |
780 |
|
* @param c the ctl value on entry |
795 |
|
else if (w.eventCount != v) |
796 |
|
return true; // update next time |
797 |
|
} |
798 |
< |
if (parallelism + (int)(nc >> AC_SHIFT) == 0 && |
798 |
> |
if ((int)c != 0 && parallelism + (int)(nc >> AC_SHIFT) == 0 && |
799 |
|
blockedCount == 0 && quiescerCount == 0) |
800 |
|
idleAwaitWork(w, nc, c, v); // quiescent |
801 |
|
for (boolean rescanned = false;;) { |