shijie xu
shijie xu

Reputation: 2097

how to check whether an event is already in disruptor ringbuffer

My disruptor/ringbuffer application has multiple producers and multiple workers. An proceducer puts an event to the RingBuffer, if the event is not in the RingBuffer. For an event, a worker query remote status according to the String id in the event, and clear the event if the status is complete.

My question is whether it is possible to check an event is already in the buffer with accepted time complexity (e,g., less than O(ring size))?

The event is like:

class MyEvent{ String id; //unique id. boolean status; //If true, then worker will remove it. }

Thanks

Upvotes: 1

Views: 172

Answers (1)

Denys
Denys

Reputation: 1488

Once event is ready and available in ring-buffer, it feeds you to registered work handler implementation 'onEvent()' method. For your case, if you want to add condition check, you can do it in an event handler or in a work handler. Basically, handlers are designed for such kind of logic. The time complexity will be O(n) as you need to check each and every event, once event is checked, you can simply put it back to the same ring buffer depends on your logic.

Upvotes: 1

Related Questions