private boolean add ( T e , boolean failWhenFull ) { final Queue < T > queue = this . getOrCreateQueue ( e ) ; this . writeLock . lock ( ) ; try { if ( this . size == this . capacity ) { if ( failWhenFull ) { throw new IllegalStateException ( "Queue is at capacity: " + this . capacity ) ; } return false ; } final boolean added = queue . add ( e ) ; if ( added ) { this . size ++ ; this . notEmpty . signal ( ) ; } return added ; } finally { this . writeLock . unlock ( ) ; } }
Adds the element to the queue