use of com.lmax.disruptor.dsl.Disruptor in project disruptor by LMAX-Exchange.
the class ThreeToOneDisruptor method main.
public static void main(String[] args) {
Executor executor = Executors.newFixedThreadPool(4);
Disruptor<DataEvent> disruptor = new Disruptor<DataEvent>(DataEvent.FACTORY, 1024, DaemonThreadFactory.INSTANCE);
TransformingHandler handler1 = new TransformingHandler(0);
TransformingHandler handler2 = new TransformingHandler(1);
TransformingHandler handler3 = new TransformingHandler(2);
CollatingHandler collator = new CollatingHandler();
disruptor.handleEventsWith(handler1, handler2, handler3).then(collator);
disruptor.start();
}
use of com.lmax.disruptor.dsl.Disruptor in project iris by chicc999.
the class DisruptorTest method testDis.
private void testDis() {
EventFactory<LongEvent> eventFactory = new LongEventFactory();
ExecutorService executor = Executors.newFixedThreadPool(1);
// RingBuffer 大小,必须是 2 的 N 次方;
int ringBufferSize = 1024 * 1024;
Disruptor<LongEvent> disruptor = new Disruptor<LongEvent>(eventFactory, ringBufferSize, executor, ProducerType.SINGLE, new YieldingWaitStrategy());
EventHandler<LongEvent> eventHandler = new LongEventHandler();
disruptor.handleEventsWith(eventHandler);
disruptor.start();
Executors.newSingleThreadExecutor().submit(new Producer(disruptor));
}
Aggregations