nl_tokens: Takes up to maxElements available data items from the queue or blocks until some become available . The returned items are wrapped in a { @link SynchRecord } which provides an interface to requeue them or send errors to their producers where the producers are still blocked .
pl_tokens: public SynchRef drainTo ( Collection < SynchRecord < E > > collection , int maxElements , boolean unblock ) { if ( collection == null ) { throw new IllegalArgumentException ( "The 'collection' parameter may not be null." ) ; } if ( collection == this ) { throw new IllegalArgumentException ( "The 'collection' parameter may not be this object." ) ; } // final Queue<E> items = this.buffer; ReentrantLock lock = this . lock ; lock . lock ( ) ; try { int n = 0 ; for ( int <mask> = ( ( maxElements >= count ) || ( maxElements < 0 ) ) ? count : maxElements ; n < max ; n ++ ) { // Extract the next record from the queue, don't signal the not full condition yet and release // producers depending on whether the caller wants to or not. collection . add ( extract ( false , unblock ) ) ; } if ( n > 0 ) { // count -= n; notFull . signalAll ( ) ; } return new SynchRefImpl ( n , collection ) ; } finally { lock . unlock ( ) ; } }