1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
package jsr166y; |
714 |
|
*/ |
715 |
|
private boolean scan(ForkJoinWorkerThread w, int a) { |
716 |
|
int g = scanGuard; // mask 0 avoids useless scans if only one active |
717 |
< |
int m = parallelism == 1 - a? 0 : g & SMASK; |
717 |
> |
int m = (parallelism == 1 - a && blockedCount == 0) ? 0 : g & SMASK; |
718 |
|
ForkJoinWorkerThread[] ws = workers; |
719 |
|
if (ws == null || ws.length <= m) // staleness check |
720 |
|
return false; |
1146 |
|
ws[k] = w; |
1147 |
|
nextWorkerIndex = k + 1; |
1148 |
|
int m = g & SMASK; |
1149 |
< |
g = k >= m? ((m << 1) + 1) & SMASK : g + (SG_UNIT<<1); |
1149 |
> |
g = k > m? ((m << 1) + 1) & SMASK : g + (SG_UNIT<<1); |
1150 |
|
} |
1151 |
|
} finally { |
1152 |
|
scanGuard = g; |