313 |
|
} |
314 |
|
|
315 |
|
/** |
316 |
< |
* Performs additional initialization and starts this thread |
316 |
> |
* Performs additional initialization and starts this thread. |
317 |
|
*/ |
318 |
|
final void start(int poolIndex, UncaughtExceptionHandler ueh) { |
319 |
|
this.poolIndex = poolIndex; |
381 |
|
if (active) { |
382 |
|
int a; // inline p.tryDecrementActiveCount |
383 |
|
active = false; |
384 |
< |
do {} while(!UNSAFE.compareAndSwapInt |
385 |
< |
(p, poolRunStateOffset, a = p.runState, a - 1)); |
384 |
> |
do {} while (!UNSAFE.compareAndSwapInt |
385 |
> |
(p, poolRunStateOffset, a = p.runState, a - 1)); |
386 |
|
} |
387 |
|
cancelTasks(); |
388 |
|
setTerminated(); |
416 |
|
// helpers for run() |
417 |
|
|
418 |
|
/** |
419 |
< |
* Find and execute tasks and check status while running |
419 |
> |
* Finds and executes tasks, and checks status while running. |
420 |
|
*/ |
421 |
|
private void mainLoop() { |
422 |
|
boolean ran = false; // true if ran a task on last step |
430 |
|
} |
431 |
|
|
432 |
|
/** |
433 |
< |
* Try to steal a task and execute it |
433 |
> |
* Tries to steal a task and execute it. |
434 |
|
* |
435 |
|
* @return true if ran a task |
436 |
|
*/ |
477 |
|
*/ |
478 |
|
private void execLocalTasks() { |
479 |
|
while (runState == 0) { |
480 |
< |
ForkJoinTask<?> t = locallyFifo? locallyDeqTask() : popTask(); |
480 |
> |
ForkJoinTask<?> t = locallyFifo ? locallyDeqTask() : popTask(); |
481 |
|
if (t != null) |
482 |
|
t.quietlyExec(); |
483 |
|
else if (sp == base) |
517 |
|
* range. This method is used only during resets and backouts. |
518 |
|
*/ |
519 |
|
private static final void writeSlot(ForkJoinTask<?>[] q, int i, |
520 |
< |
ForkJoinTask<?> t) { |
520 |
> |
ForkJoinTask<?> t) { |
521 |
|
UNSAFE.putObjectVolatile(q, (i << qShift) + qBase, t); |
522 |
|
} |
523 |
|
|
628 |
|
} |
629 |
|
|
630 |
|
/** |
631 |
< |
* Returns next task or null if empty or contended |
631 |
> |
* Returns next task, or null if empty or contended. |
632 |
|
*/ |
633 |
|
final ForkJoinTask<?> peekTask() { |
634 |
|
ForkJoinTask<?>[] q = queue; |
670 |
|
* Computes next value for random victim probe in scan(). Scans |
671 |
|
* don't require a very high quality generator, but also not a |
672 |
|
* crummy one. Marsaglia xor-shift is cheap and works well enough. |
673 |
< |
* Note: This is manually inlined in scan() |
673 |
> |
* Note: This is manually inlined in scan(). |
674 |
|
*/ |
675 |
|
private static final int xorShift(int r) { |
676 |
|
r ^= r << 13; |
776 |
|
} |
777 |
|
|
778 |
|
/** |
779 |
< |
* Sets state to TERMINATED. Called only by onTermination() |
779 |
> |
* Sets state to TERMINATED. Called only by onTermination(). |
780 |
|
*/ |
781 |
|
private void setTerminated() { |
782 |
|
int s; |
897 |
|
if (active || |
898 |
|
(active = UNSAFE.compareAndSwapInt(p, poolRunStateOffset, |
899 |
|
a = p.runState, a + 1))) |
900 |
< |
return locallyFifo? locallyDeqTask() : popTask(); |
900 |
> |
return locallyFifo ? locallyDeqTask() : popTask(); |
901 |
|
} |
902 |
|
return null; |
903 |
|
} |
1126 |
|
} |
1127 |
|
if (p.isQuiescent()) { |
1128 |
|
active = true; // re-activate |
1129 |
< |
do {} while(!UNSAFE.compareAndSwapInt |
1130 |
< |
(p, poolRunStateOffset, a = p.runState, a+1)); |
1129 |
> |
do {} while (!UNSAFE.compareAndSwapInt |
1130 |
> |
(p, poolRunStateOffset, a = p.runState, a+1)); |
1131 |
|
return; |
1132 |
|
} |
1133 |
|
} |