Search in sources :

Example 1 with RingBuffer

use of com.lmax.disruptor.RingBuffer in project disruptor by LMAX-Exchange.

the class DisruptorTest method should.

@Test
public void should() throws Exception {
    RingBuffer<TestEvent> rb = disruptor.getRingBuffer();
    BatchEventProcessor<TestEvent> b1 = new BatchEventProcessor<TestEvent>(rb, rb.newBarrier(), new SleepingEventHandler());
    EventProcessorFactory<TestEvent> b2 = new EventProcessorFactory<TestEvent>() {

        @Override
        public EventProcessor createEventProcessor(RingBuffer<TestEvent> ringBuffer, Sequence[] barrierSequences) {
            return new BatchEventProcessor<TestEvent>(ringBuffer, ringBuffer.newBarrier(barrierSequences), new SleepingEventHandler());
        }
    };
    disruptor.handleEventsWith(b1).then(b2);
    disruptor.start();
}
Also used : SleepingEventHandler(com.lmax.disruptor.dsl.stubs.SleepingEventHandler) TestEvent(com.lmax.disruptor.support.TestEvent) BatchEventProcessor(com.lmax.disruptor.BatchEventProcessor) RingBuffer(com.lmax.disruptor.RingBuffer) Test(org.junit.Test)

Aggregations

BatchEventProcessor (com.lmax.disruptor.BatchEventProcessor)1 RingBuffer (com.lmax.disruptor.RingBuffer)1 SleepingEventHandler (com.lmax.disruptor.dsl.stubs.SleepingEventHandler)1 TestEvent (com.lmax.disruptor.support.TestEvent)1 Test (org.junit.Test)1