private E xfer(E e,boolean haveData,int how,long nanos){
  if (haveData && (e == null))   throw new NullPointerException();
  Node s=null;
  retry:   for (; ; ) {
    for (Node h=head, p=h; p != null; ) {
      boolean isData=p.isData;
      Object item=p.item;
      if (item != p && (item != null) == isData) {
        if (isData == haveData)         break;
        if (p.casItem(item,e)) {
          for (Node q=p; q != h; ) {
            Node n=q.next;
            if (head == h && casHead(h,n == null ? q : n)) {
              h.forgetNext();
              break;
            }
            if ((h=head) == null || (q=h.next) == null || !q.isMatched())             break;
          }
          LockSupport.unpark(p.waiter);
          return LinkedTransferQueue.<E>cast(item);
        }
      }
      Node n=p.next;
      p=(p != n) ? n : (h=head);
    }
    if (how != NOW) {
      if (s == null)       s=new Node(e,haveData);
      Node pred=tryAppend(s,haveData);
      if (pred == null)       continue retry;
      if (how != ASYNC)       return awaitMatch(s,pred,e,(how == TIMED),nanos);
    }
    return e;
  }
}

private E xfer ( E e , boolean haveData , int how , long nanos ) { if ( haveData && ( e == null ) ) throw new NullPointerException ( ) ; Node s = null ; retry : for ( ; ; ) { for ( Node h = head , p = h ; p != null ; ) { boolean isData = p . isData ; Object item = p . item ; if ( item != p && ( item != null ) == isData ) { if ( isData == haveData ) break ; if ( p . casItem ( item , e ) ) { for ( Node q = p ; q != h ; ) { Node n = q . next ; if ( head == h && casHead ( h , n == null ? q : n ) ) { h . forgetNext ( ) ; break ; } if ( ( h = head ) == null || ( q = h . next ) == null || ! q . isMatched ( ) ) break ; } LockSupport . unpark ( p . waiter ) ; return LinkedTransferQueue . < E > cast ( item ) ; } } Node n = p . next ; p = ( p != n ) ? n : ( h = head ) ; } if ( how != NOW ) { if ( s == null ) s = new Node ( e , haveData ) ; Node pred = tryAppend ( s , haveData ) ; if ( pred == null ) continue retry ; if ( how != ASYNC ) return awaitMatch ( s , pred , e , ( how == TIMED ) , nanos ) ; } return e ; } }
implements all queuing methods . see above for explanation .
