public void add ( T item ) { CompletableFuture < Queue < T >> pending ; Queue < T > result = null ; synchronized ( this . contents ) { Exceptions . checkNotClosed ( this . closed , this ) ; this . contents . addLast ( item ) ; pending = this . pendingTake ; this . pendingTake = null ; if ( pending != null ) { result = fetch ( this . contents . size ( ) ) ; } } if ( pending != null ) { pending . complete ( result ) ; } }
Adds a new item to the queue .