use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldHonourDependenciesForCustomProcessors.
@Test
public void shouldHonourDependenciesForCustomProcessors() throws Exception {
final CountDownLatch countDownLatch = new CountDownLatch(2);
final EventHandler<TestEvent> eventHandler = new EventHandlerStub<TestEvent>(countDownLatch);
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
disruptor.handleEventsWith(delayedEventHandler).then(new EventProcessorFactory<TestEvent>() {
@Override
public EventProcessor createEventProcessor(final RingBuffer<TestEvent> ringBuffer, final Sequence[] barrierSequences) {
assertSame("Should have had a barrier sequence", 1, barrierSequences.length);
return new BatchEventProcessor<TestEvent>(disruptor.getRingBuffer(), ringBuffer.newBarrier(barrierSequences), eventHandler);
}
});
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler);
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldBlockProducerUntilAllEventProcessorsHaveAdvanced.
@Test
public void shouldBlockProducerUntilAllEventProcessorsHaveAdvanced() throws Exception {
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
disruptor.handleEventsWith(delayedEventHandler);
final RingBuffer<TestEvent> ringBuffer = disruptor.start();
delayedEventHandler.awaitStart();
final StubPublisher stubPublisher = new StubPublisher(ringBuffer);
try {
executor.newThread(stubPublisher).start();
assertProducerReaches(stubPublisher, 4, true);
delayedEventHandler.processEvent();
delayedEventHandler.processEvent();
delayedEventHandler.processEvent();
delayedEventHandler.processEvent();
delayedEventHandler.processEvent();
assertProducerReaches(stubPublisher, 5, false);
} finally {
stubPublisher.halt();
}
}
Aggregations