139 |
|
private static final int MAXIMUM_QUEUE_CAPACITY = 1 << 28; |
140 |
|
|
141 |
|
/** |
142 |
< |
* The pool this thread works in. Accessed directly by ForkJoinTask |
142 |
> |
* The pool this thread works in. Accessed directly by ForkJoinTask. |
143 |
|
*/ |
144 |
|
final ForkJoinPool pool; |
145 |
|
|
167 |
|
* Activity status. When true, this worker is considered active. |
168 |
|
* Must be false upon construction. It must be true when executing |
169 |
|
* tasks, and BEFORE stealing a task. It must be false before |
170 |
< |
* calling pool.sync |
170 |
> |
* calling pool.sync. |
171 |
|
*/ |
172 |
|
private boolean active; |
173 |
|
|
190 |
|
|
191 |
|
/** |
192 |
|
* Index of this worker in pool array. Set once by pool before |
193 |
< |
* running, and accessed directly by pool during cleanup etc |
193 |
> |
* running, and accessed directly by pool during cleanup etc. |
194 |
|
*/ |
195 |
|
int poolIndex; |
196 |
|
|
293 |
|
} |
294 |
|
|
295 |
|
/** |
296 |
< |
* Tries to set status to active; fails on contention. |
296 |
> |
* Tries to set status to inactive; fails on contention. |
297 |
|
*/ |
298 |
|
private boolean tryInactivate() { |
299 |
|
if (active) { |
371 |
|
/** |
372 |
|
* Performs cleanup associated with termination of this worker |
373 |
|
* thread. If you override this method, you must invoke |
374 |
< |
* super.onTermination at the end of the overridden method. |
374 |
> |
* {@code super.onTermination} at the end of the overridden method. |
375 |
|
* |
376 |
|
* @param exception the exception causing this thread to abort due |
377 |
|
* to an unrecoverable error, or null if completed normally |
383 |
|
ForkJoinTask<?> t = popTask(); |
384 |
|
if (t != null) |
385 |
|
t.quietlyExec(); |
386 |
< |
} catch(Throwable ex) { |
386 |
> |
} catch (Throwable ex) { |
387 |
|
exception = ex; |
388 |
|
} |
389 |
|
} |
390 |
|
// Cancel other tasks, transition status, notify pool, and |
391 |
|
// propagate exception to uncaught exception handler |
392 |
|
try { |
393 |
< |
do;while (!tryInactivate()); // ensure inactive |
393 |
> |
do {} while (!tryInactivate()); // ensure inactive |
394 |
|
cancelTasks(); |
395 |
|
runState = TERMINATED; |
396 |
|
pool.workerTerminated(this); |
671 |
|
/** |
672 |
|
* Returns true if at least one worker in the given array appears |
673 |
|
* to have at least one queued task. |
674 |
+ |
* |
675 |
|
* @param ws array of workers |
676 |
|
*/ |
677 |
|
static boolean hasQueuedTasks(ForkJoinWorkerThread[] ws) { |
708 |
|
} |
709 |
|
|
710 |
|
/** |
711 |
< |
* Scans, returning early if joinMe done |
711 |
> |
* Scans, returning early if joinMe done. |
712 |
|
*/ |
713 |
|
final ForkJoinTask<?> scanWhileJoining(ForkJoinTask<?> joinMe) { |
714 |
|
ForkJoinTask<?> t = pollTask(); |
720 |
|
} |
721 |
|
|
722 |
|
/** |
723 |
< |
* Runs tasks until pool isQuiescent. |
723 |
> |
* Runs tasks until {@code pool.isQuiescent()}. |
724 |
|
*/ |
725 |
|
final void helpQuiescePool() { |
726 |
|
for (;;) { |
730 |
|
else if (tryInactivate() && pool.isQuiescent()) |
731 |
|
break; |
732 |
|
} |
733 |
< |
do;while (!tryActivate()); // re-activate on exit |
733 |
> |
do {} while (!tryActivate()); // re-activate on exit |
734 |
|
} |
735 |
|
|
736 |
|
// Temporary Unsafe mechanics for preliminary release |