728 |
|
* Releases workers blocked on a count not equal to current count. |
729 |
|
* Normally called after precheck that eventWaiters isn't zero to |
730 |
|
* avoid wasted array checks. Gives up upon a change in count or |
731 |
< |
* upon releasing two workers, letting others take over. |
731 |
> |
* upon releasing four workers, letting others take over. |
732 |
|
*/ |
733 |
|
private void releaseEventWaiters() { |
734 |
|
ForkJoinWorkerThread[] ws = workers; |
735 |
|
int n = ws.length; |
736 |
|
long h = eventWaiters; |
737 |
|
int ec = eventCount; |
738 |
< |
boolean releasedOne = false; |
738 |
> |
int releases = 4; |
739 |
|
ForkJoinWorkerThread w; int id; |
740 |
|
while ((id = (((int)h) & WAITER_ID_MASK) - 1) >= 0 && |
741 |
|
(int)(h >>> EVENT_COUNT_SHIFT) != ec && |
743 |
|
if (UNSAFE.compareAndSwapLong(this, eventWaitersOffset, |
744 |
|
h, w.nextWaiter)) { |
745 |
|
LockSupport.unpark(w); |
746 |
< |
if (releasedOne) // exit on second release |
746 |
> |
if (--releases == 0) |
747 |
|
break; |
748 |
– |
releasedOne = true; |
748 |
|
} |
749 |
|
if (eventCount != ec) |
750 |
|
break; |