private Object timedGet(long nanos) throws TimeoutException {
  if (Thread.interrupted())   return null;
  if (nanos > 0L) {
    long d=System.nanoTime() + nanos;
    long deadline=(d == 0L) ? 1L : d;
    Signaller q=null;
    boolean queued=false;
    Object r;
    while ((r=result) == null) {
      if (q == null) {
        q=new Signaller(true,nanos,deadline);
        if (Thread.currentThread() instanceof ForkJoinWorkerThread)         ForkJoinPool.helpAsyncBlocker(defaultExecutor(),q);
      }
 else       if (!queued)       queued=tryPushStack(q);
 else       if (q.nanos <= 0L)       break;
 else {
        try {
          ForkJoinPool.managedBlock(q);
        }
 catch (        InterruptedException ie) {
          q.interrupted=true;
        }
        if (q.interrupted)         break;
      }
    }
    if (q != null && queued) {
      q.thread=null;
      if (r == null)       cleanStack();
    }
    if (r != null || (r=result) != null)     postComplete();
    if (r != null || (q != null && q.interrupted))     return r;
  }
  throw new TimeoutException();
}

private Object timedGet ( long nanos ) throws TimeoutException { if ( Thread . interrupted ( ) ) return null ; if ( nanos > 0L ) { long d = System . nanoTime ( ) + nanos ; long deadline = ( d == 0L ) ? 1L : d ; Signaller q = null ; boolean queued = false ; Object r ; while ( ( r = result ) == null ) { if ( q == null ) { q = new Signaller ( true , nanos , deadline ) ; if ( Thread . currentThread ( ) instanceof ForkJoinWorkerThread ) ForkJoinPool . helpAsyncBlocker ( defaultExecutor ( ) , q ) ; } else if ( ! queued ) queued = tryPushStack ( q ) ; else if ( q . nanos <= 0L ) break ; else { try { ForkJoinPool . managedBlock ( q ) ; } catch ( InterruptedException ie ) { q . interrupted = true ; } if ( q . interrupted ) break ; } } if ( q != null && queued ) { q . thread = null ; if ( r == null ) cleanStack ( ) ; } if ( r != null || ( r = result ) != null ) postComplete ( ) ; if ( r != null || ( q != null && q . interrupted ) ) return r ; } throw new TimeoutException ( ) ; }
returns raw result after waiting , or null if interrupted , or throws timeoutexception on timeout .
