/** * If lock is available, poll stale refs and remove them. * Called from ForkJoinPool when pools become quiescent. */ static final void helpExpungeStaleExceptions() { final ReentrantLock lock = exceptionTableLock; if (lock.tryLock()) { try { expungeStaleExceptions(); } finally { lock.unlock(); } } }
/** * Removes exception node and clears status */ private void clearExceptionalCompletion() { int h = System.identityHashCode(this); final ReentrantLock lock = exceptionTableLock; lock.lock(); try { ExceptionNode[] t = exceptionTable; int i = h & (t.length - 1); ExceptionNode e = t[i]; ExceptionNode pred = null; while (e != null) { ExceptionNode next = e.next; if (e.get() == this) { if (pred == null) t[i] = next; else pred.next = next; break; } pred = e; e = next; } expungeStaleExceptions(); status = 0; } finally { lock.unlock(); } }
lock.lock(); try { expungeStaleExceptions(); ExceptionNode[] t = exceptionTable; e = t[h & (t.length - 1)];
/** * Records exception and sets status. * * @return status on exit */ final int recordExceptionalCompletion(Throwable ex) { int s; if ((s = status) >= 0) { int h = System.identityHashCode(this); final ReentrantLock lock = exceptionTableLock; lock.lock(); try { expungeStaleExceptions(); ExceptionNode[] t = exceptionTable; int i = h & (t.length - 1); for (ExceptionNode e = t[i]; ; e = e.next) { if (e == null) { t[i] = new ExceptionNode(this, ex, t[i]); break; } if (e.get() == this) // already present break; } } finally { lock.unlock(); } s = setCompletion(EXCEPTIONAL); } return s; }
/** * If lock is available, poll stale refs and remove them. * Called from ForkJoinPool when pools become quiescent. */ static final void helpExpungeStaleExceptions() { final ReentrantLock lock = exceptionTableLock; if (lock.tryLock()) { try { expungeStaleExceptions(); } finally { lock.unlock(); } } }
/** * Removes exception node and clears status */ private void clearExceptionalCompletion() { int h = System.identityHashCode(this); final ReentrantLock lock = exceptionTableLock; lock.lock(); try { ExceptionNode[] t = exceptionTable; int i = h & (t.length - 1); ExceptionNode e = t[i]; ExceptionNode pred = null; while (e != null) { ExceptionNode next = e.next; if (e.get() == this) { if (pred == null) t[i] = next; else pred.next = next; break; } pred = e; e = next; } expungeStaleExceptions(); status = 0; } finally { lock.unlock(); } }
lock.lock(); try { expungeStaleExceptions(); ExceptionNode[] t = exceptionTable; e = t[h & (t.length - 1)];
/** * Records exception and sets exceptional completion. * * @return status on exit */ private int setExceptionalCompletion(Throwable ex) { int h = System.identityHashCode(this); final ReentrantLock lock = exceptionTableLock; lock.lock(); try { expungeStaleExceptions(); ExceptionNode[] t = exceptionTable; int i = h & (t.length - 1); for (ExceptionNode e = t[i]; ; e = e.next) { if (e == null) { t[i] = new ExceptionNode(this, ex, t[i]); break; } if (e.get() == this) // already present break; } } finally { lock.unlock(); } return setCompletion(EXCEPTIONAL); }