labelUpdatesApply.await();
@Test void mustApplyWorkAsyncEvenWhenInterrupted() throws Exception { Thread.currentThread().interrupt(); sync.applyAsync( new AddWork( 10 ) ).await(); assertThat( sum.sum(), is( 10L ) ); assertTrue( Thread.interrupted() ); }
@Test void mustApplyWorkAsync() throws Exception { AsyncApply a = sync.applyAsync( new AddWork( 10 ) ); a.await(); assertThat( sum.sum(), is( 10L ) ); AsyncApply b = sync.applyAsync( new AddWork( 20 ) ); AsyncApply c = sync.applyAsync( new AddWork( 30 ) ); b.await(); c.await(); assertThat( sum.sum(), is( 60L ) ); }
@Test void mustCombineWorkAsync() throws Exception { makeWorkStuckAtSemaphore( 1 ); AsyncApply a = sync.applyAsync( new AddWork( 1 ) ); AsyncApply b = sync.applyAsync( new AddWork( 1 ) ); AsyncApply c = sync.applyAsync( new AddWork( 1 ) ); semaphore.release( 2 ); a.await(); b.await(); c.await(); assertThat( sum.sum(), is( 4L ) ); assertThat( count.sum(), is( 2L ) ); }
labelUpdatesApply.await();