198 |
|
* Initialized in onStart, to improve memory locality. |
199 |
|
*/ |
200 |
|
private ForkJoinTask<?>[] queue; |
201 |
< |
|
201 |
> |
|
202 |
|
/** |
203 |
|
* Index (mod queue.length) of least valid queue slot, which is |
204 |
|
* always the next position to steal from if nonempty. |
269 |
|
* pool-wide. |
270 |
|
*/ |
271 |
|
private final boolean locallyFifo; |
272 |
< |
|
272 |
> |
|
273 |
|
/** |
274 |
|
* Index of this worker in pool array. Set once by pool before |
275 |
|
* running, and accessed directly by pool to locate this worker in |
295 |
|
* others. |
296 |
|
*/ |
297 |
|
private volatile ForkJoinTask<?> currentJoin; |
298 |
< |
|
298 |
> |
|
299 |
|
/** |
300 |
|
* The task most recently stolen from another worker (or |
301 |
|
* submission queue). Not volatile because always read/written in |
431 |
|
currentSteal = null; |
432 |
|
emptyScans = 0; |
433 |
|
} |
434 |
< |
else |
434 |
> |
else |
435 |
|
++emptyScans; |
436 |
|
} |
437 |
|
} |
570 |
|
|
571 |
|
/** |
572 |
|
* Returns a popped task, or null if empty. Assumes active status. |
573 |
< |
* Called only by current thread. |
573 |
> |
* Called only by current thread. |
574 |
|
*/ |
575 |
|
final ForkJoinTask<?> popTask() { |
576 |
|
int s; |
963 |
|
ForkJoinTask<?> t; |
964 |
|
int i = (q.length - 1) & --s; |
965 |
|
long u = (i << qShift) + qBase; // raw offset |
966 |
< |
if ((t = q[i]) != null && |
966 |
> |
if ((t = q[i]) != null && |
967 |
|
UNSAFE.compareAndSwapObject(q, u, t, null)) { |
968 |
|
/* |
969 |
|
* This recheck (and similarly in helpJoinTask) |
1025 |
|
ForkJoinTask<?>[] q; |
1026 |
|
while ((b = v.base) != v.sp && (q = v.queue) != null) { |
1027 |
|
int i = (q.length - 1) & b; |
1028 |
< |
long u = (i << qShift) + qBase; |
1028 |
> |
long u = (i << qShift) + qBase; |
1029 |
|
ForkJoinTask<?> t = q[i]; |
1030 |
|
if (task.status < 0) // stale |
1031 |
|
continue restart; |
1033 |
|
if (t == null) // producer stalled |
1034 |
|
continue restart; // retry via restart |
1035 |
|
if (UNSAFE.compareAndSwapObject(q, u, t, null)) { |
1036 |
< |
if (joinMe.status < 0) { |
1036 |
> |
if (joinMe.status < 0) { |
1037 |
|
UNSAFE.putObjectVolatile(q, u, t); |
1038 |
|
return; // back out on cancel |
1039 |
|
} |