@Override public void waitFor( long value ) throws InterruptedException { delegate.waitFor( value ); }
private WorkerCommand<Void, Object> awaitHead( final IdOrderingQueue queue, final long id ) { return state -> { queue.waitFor( id ); return null; }; } }
transactionOrdering.waitFor( activeTransactionId );
@Test public void shouldOfferQueueABunchOfIds() throws Exception { // GIVEN IdOrderingQueue queue = new SynchronizedArrayIdOrderingQueue( 5 ); // WHEN for ( int i = 0; i < 7; i++ ) { queue.offer( i ); } // THEN for ( int i = 0; i < 7; i++ ) { assertFalse( queue.isEmpty() ); queue.waitFor( i ); queue.removeChecked( i ); } assertTrue( queue.isEmpty() ); }
@Test public void shouldOfferAwaitAndRemoveRoundAndRound() throws Exception { // GIVEN IdOrderingQueue queue = new SynchronizedArrayIdOrderingQueue( 5 ); long offeredId = 0; long awaitedId = 0; queue.offer( offeredId++ ); queue.offer( offeredId++ ); // WHEN for ( int i = 0; i < 20; i++ ) { queue.waitFor( awaitedId ); queue.removeChecked( awaitedId++ ); queue.offer( offeredId++ ); assertFalse( queue.isEmpty() ); } // THEN queue.removeChecked( awaitedId++ ); queue.removeChecked( awaitedId ); assertTrue( queue.isEmpty() ); }
transactionOrdering.waitFor( activeTransactionId );