Search in sources :

Example 1 with LongEvent

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

the class WaitForShutdown method main.

public static void main(String[] args) throws TimeoutException, InterruptedException {
    Disruptor<LongEvent> disruptor = new Disruptor<LongEvent>(LongEvent.FACTORY, 16, DaemonThreadFactory.INSTANCE);
    CountDownLatch shutdownLatch = new CountDownLatch(2);
    disruptor.handleEventsWith(new Handler(shutdownLatch)).then(new Handler(shutdownLatch));
    disruptor.start();
    long next = disruptor.getRingBuffer().next();
    disruptor.getRingBuffer().get(next).set(next);
    disruptor.getRingBuffer().publish(next);
    disruptor.shutdown(10, TimeUnit.SECONDS);
    shutdownLatch.await();
    System.out.println(value);
}
Also used : LongEvent(com.lmax.disruptor.support.LongEvent) EventHandler(com.lmax.disruptor.EventHandler) Disruptor(com.lmax.disruptor.dsl.Disruptor) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

EventHandler (com.lmax.disruptor.EventHandler)1 Disruptor (com.lmax.disruptor.dsl.Disruptor)1 LongEvent (com.lmax.disruptor.support.LongEvent)1 CountDownLatch (java.util.concurrent.CountDownLatch)1