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; |
384 |
|
* periods. However, since we do not know when the last joiner |
385 |
|
* completes, we must use weak references and expunge them. We do |
386 |
|
* so on each operation (hence full locking). Also, some thread in |
387 |
< |
* any ForkJoinPool will call helpExpunge when its pool becomes |
388 |
< |
* isQuiescent. |
387 |
> |
* any ForkJoinPool will call helpExpungeStaleExceptions when its |
388 |
> |
* pool becomes isQuiescent. |
389 |
|
*/ |
390 |
|
static final class ExceptionNode extends WeakReference<ForkJoinTask<?>>{ |
391 |
|
final Throwable ex; |
392 |
|
ExceptionNode next; |
393 |
< |
final long thrower; |
393 |
> |
final long thrower; // use id not ref to avoid weak cycles |
394 |
|
ExceptionNode(ForkJoinTask<?> task, Throwable ex, ExceptionNode next) { |
395 |
|
super(task, exceptionTableRefQueue); |
396 |
|
this.ex = ex; |
406 |
|
*/ |
407 |
|
private int setExceptionalCompletion(Throwable ex) { |
408 |
|
int h = System.identityHashCode(this); |
409 |
< |
ReentrantLock lock = exceptionTableLock; |
409 |
> |
final ReentrantLock lock = exceptionTableLock; |
410 |
|
lock.lock(); |
411 |
|
try { |
412 |
|
expungeStaleExceptions(); |
431 |
|
*/ |
432 |
|
private void clearExceptionalCompletion() { |
433 |
|
int h = System.identityHashCode(this); |
434 |
< |
ReentrantLock lock = exceptionTableLock; |
434 |
> |
final ReentrantLock lock = exceptionTableLock; |
435 |
|
lock.lock(); |
436 |
|
try { |
437 |
|
ExceptionNode[] t = exceptionTable; |
476 |
|
return null; |
477 |
|
int h = System.identityHashCode(this); |
478 |
|
ExceptionNode e; |
479 |
< |
ReentrantLock lock = exceptionTableLock; |
479 |
> |
final ReentrantLock lock = exceptionTableLock; |
480 |
|
lock.lock(); |
481 |
|
try { |
482 |
|
expungeStaleExceptions(); |
542 |
|
} |
543 |
|
|
544 |
|
/** |
545 |
< |
* If lock is available, poll any stale refs and remove them. |
545 |
> |
* If lock is available, poll stale refs and remove them. |
546 |
|
* Called from ForkJoinPool when pools become quiescent. |
547 |
|
*/ |
548 |
|
static final void helpExpungeStaleExceptions() { |
549 |
< |
ReentrantLock lock = exceptionTableLock; |
549 |
> |
final ReentrantLock lock = exceptionTableLock; |
550 |
|
if (lock.tryLock()) { |
551 |
|
try { |
552 |
|
expungeStaleExceptions(); |