Reputation: 3328
I am running a disruptor instance with following event handler:
int NUM_EVENT_PROCESSORS = 5;
executor = Executors.newFixedThreadPool(NUM_EVENT_PROCESSORS);
EventFactory factory = new EventFactory();
System.out.println("Starting Disruptor");
disruptor = new Disruptor<>(factory, RING_SIZE, executor, ProducerType.SINGLE, new BlockingWaitStrategy());
disruptor.handleEventsWith(new Logger(), new Replicator(), new Logic());
disruptor.start();
I have discovered an instance where the Replicator() thread hung and it blocked the Logic() thread.
If there is 1 event in the ringbuffer, do the disruptor threads work sequentially?
Upvotes: 0
Views: 914
Reputation: 3328
Ok this was my own error. I run 2 sets of disruptors (one for client side and one for provider side) and my client side code was the following:
disruptor.handleEventsWith(new Logger(), new Replicator()).then(new Logic());
while my provider side code was the following:
disruptor.handleEventsWith(new Logger(), new Replicator(), new Logic());
so the disruptor instance on the client side was doing as it was told. If the replicator blocks so does the logic thread.
Thanks stack overflow for making me check my code over again.
Upvotes: 1
Reputation: 191
Each EventHandler is run in a 'consumer' thread independent from other consumer threads. The only time the other consumer threads can be affected(slowed down) is when one consumer is so slow that the RingBuffer becomes full resulting in producers being blocked,which in turn affects the consumers. Code for consumer thread(i.e code running EventHandler)
Upvotes: 1