@After public void tearDown() throws Exception { for (DelayedEventHandler delayedEventHandler : delayedEventHandlers) { delayedEventHandler.stopWaiting(); } disruptor.halt(); executor.joinAllThreads(); }
private void ensureTwoEventsProcessedAccordingToDependencies( final CountDownLatch countDownLatch, final DelayedEventHandler... dependencies) throws InterruptedException { publishEvent(); publishEvent(); for (DelayedEventHandler dependency : dependencies) { assertThatCountDownLatchEquals(countDownLatch, 2L); dependency.processEvent(); dependency.processEvent(); } assertThatCountDownLatchIsZero(countDownLatch); }
@Test public void shouldBlockProducerUntilAllEventProcessorsHaveAdvanced() throws Exception { final DelayedEventHandler delayedEventHandler = createDelayedEventHandler(); disruptor.handleEventsWith(delayedEventHandler); final RingBuffer<TestEvent> ringBuffer = disruptor.start(); final StubPublisher stubPublisher = new StubPublisher(ringBuffer); try { executor.execute(stubPublisher); assertProducerReaches(stubPublisher, 4, true); delayedEventHandler.processEvent(); delayedEventHandler.processEvent(); delayedEventHandler.processEvent(); delayedEventHandler.processEvent(); delayedEventHandler.processEvent(); assertProducerReaches(stubPublisher, 5, false); } finally { stubPublisher.halt(); } }