1047 |
|
ASHIFT = 31 - Integer.numberOfLeadingZeros(s); |
1048 |
|
} |
1049 |
|
} |
1050 |
+ |
|
1051 |
|
/** |
1052 |
|
* Per-thread records for threads that submit to pools. Currently |
1053 |
|
* holds only pseudo-random seed / index that is used to choose |
1104 |
|
private static final RuntimePermission modifyThreadPermission; |
1105 |
|
|
1106 |
|
/** |
1107 |
< |
* Per-thread submission bookeeping. Shared across all pools |
1107 |
> |
* Per-thread submission bookkeeping. Shared across all pools |
1108 |
|
* to reduce ThreadLocal pollution and because random motion |
1109 |
|
* to avoid contention in one pool is likely to hold for others. |
1110 |
|
*/ |
1301 |
|
* |
1302 |
|
* @param w the worker's queue |
1303 |
|
*/ |
1303 |
– |
|
1304 |
|
final void registerWorker(WorkQueue w) { |
1305 |
|
Mutex lock = this.lock; |
1306 |
|
lock.lock(); |
1307 |
|
try { |
1308 |
|
WorkQueue[] ws = workQueues; |
1309 |
|
if (w != null && ws != null) { // skip on shutdown/failure |
1310 |
< |
int rs, n = ws.length, m = n - 1; |
1310 |
> |
int rs, n = ws.length, m = n - 1; |
1311 |
|
int s = nextSeed += SEED_INCREMENT; // rarely-colliding sequence |
1312 |
|
w.seed = (s == 0) ? 1 : s; // ensure non-zero seed |
1313 |
|
int r = (s << 1) | 1; // use odd-numbered indices |
1518 |
|
* awaiting signal, |
1519 |
|
* |
1520 |
|
* @param w the worker (via its WorkQueue) |
1521 |
< |
* @return a task or null of none found |
1521 |
> |
* @return a task or null if none found |
1522 |
|
*/ |
1523 |
|
private final ForkJoinTask<?> scan(WorkQueue w) { |
1524 |
|
WorkQueue[] ws; // first update random seed |