public void put ( final E e , final long timeStamp ) throws InterruptedException { final ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; try { // mask is a.length - 1 while ( timeStamp - this . timeStamp > mask ) newSpaceAvailable . await ( ) ; final int timeOffset = ( int ) ( timeStamp - this . timeStamp ) ; assert a [ start + timeOffset & mask ] == null : a [ start + timeOffset & mask ] ; a [ start + timeOffset & mask ] = e ; ++ count ; if ( timeOffset == 0 ) nextObjectReady . signal ( ) ; } finally { lock . unlock ( ) ; } }
Inserts an element with given timestamp waiting for space to become available if the timestamp of the element minus the current timestamp of the queue exceeds the queue capacity .