--- jsr166/src/jsr166y/ForkJoinTask.java 2010/08/11 19:44:30 1.54 +++ jsr166/src/jsr166y/ForkJoinTask.java 2010/08/29 23:34:46 1.55 @@ -214,7 +214,9 @@ public abstract class ForkJoinTask im } /** - * Blocks a worker thread until completion. Called only by pool. + * Blocks a worker thread until completion. Called only by + * pool. Currently unused -- pool-based waits use timeout + * version below. */ final void internalAwaitDone() { int s; // the odd construction reduces lock bias effects @@ -231,6 +233,28 @@ public abstract class ForkJoinTask im } /** + * Blocks a worker thread until completed or timed out. Called + * only by pool. + * + * @return status on exit + */ + final int internalAwaitDone(long millis) { + int s; + if ((s = status) >= 0) { + try { + synchronized(this) { + if (UNSAFE.compareAndSwapInt(this, statusOffset, s,SIGNAL)) + wait(millis, 0); + } + } catch (InterruptedException ie) { + cancelIfTerminating(); + } + s = status; + } + return s; + } + + /** * Blocks a non-worker-thread until completion. */ private void externalAwaitDone() {