Search in sources :

Example 1 with StubPublisher

use of com.lmax.disruptor.dsl.stubs.StubPublisher 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();
    }
}
Also used : TestEvent(com.lmax.disruptor.support.TestEvent) StubPublisher(com.lmax.disruptor.dsl.stubs.StubPublisher) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) Test(org.junit.Test)

Aggregations

DelayedEventHandler (com.lmax.disruptor.dsl.stubs.DelayedEventHandler)1 StubPublisher (com.lmax.disruptor.dsl.stubs.StubPublisher)1 TestEvent (com.lmax.disruptor.support.TestEvent)1 Test (org.junit.Test)1