private E awaitMatch(Node s,Node pred,E e,boolean timed,long nanos){
  final long deadline=timed ? System.nanoTime() + nanos : 0L;
  Thread w=Thread.currentThread();
  int spins=-1;
  ThreadLocalRandom randomYields=null;
  for (; ; ) {
    Object item=s.item;
    if (item != e) {
      s.forgetContents();
      return LinkedTransferQueue.<E>cast(item);
    }
    if ((w.isInterrupted() || (timed && nanos <= 0)) && s.casItem(e,s)) {
      unsplice(pred,s);
      return e;
    }
    if (spins < 0) {
      if ((spins=spinsFor(pred,s.isData)) > 0)       randomYields=ThreadLocalRandom.current();
    }
 else     if (spins > 0) {
      --spins;
      if (randomYields.nextInt(CHAINED_SPINS) == 0)       Thread.yield();
    }
 else     if (s.waiter == null) {
      s.waiter=w;
    }
 else     if (timed) {
      nanos=deadline - System.nanoTime();
      if (nanos > 0L)       LockSupport.parkNanos(this,nanos);
    }
 else {
      LockSupport.park(this);
    }
  }
}

private E awaitMatch ( Node s , Node pred , E e , boolean timed , long nanos ) { final long deadline = timed ? System . nanoTime ( ) + nanos : 0L ; Thread w = Thread . currentThread ( ) ; int spins = - 1 ; ThreadLocalRandom randomYields = null ; for ( ; ; ) { Object item = s . item ; if ( item != e ) { s . forgetContents ( ) ; return LinkedTransferQueue . < E > cast ( item ) ; } if ( ( w . isInterrupted ( ) || ( timed && nanos <= 0 ) ) && s . casItem ( e , s ) ) { unsplice ( pred , s ) ; return e ; } if ( spins < 0 ) { if ( ( spins = spinsFor ( pred , s . isData ) ) > 0 ) randomYields = ThreadLocalRandom . current ( ) ; } else if ( spins > 0 ) { -- spins ; if ( randomYields . nextInt ( CHAINED_SPINS ) == 0 ) Thread . yield ( ) ; } else if ( s . waiter == null ) { s . waiter = w ; } else if ( timed ) { nanos = deadline - System . nanoTime ( ) ; if ( nanos > 0L ) LockSupport . parkNanos ( this , nanos ) ; } else { LockSupport . park ( this ) ; } } }
spins / yields / blocks until node s is matched or caller gives up .
