简体   繁体   中英

Pollable disruptor

I did quite a bit of research, but I can not find the solution yet. I would like to find a pollable ring buffer , similar to the LMAX disruptor one. I have many publishers and one reader.

The problem with disrupto r is that it uses its own dedicated thread (pool) to read messages, but i would like to read them from the separate thread, which does other things as well.

One alternative I see is to use ManyToOneConcurrentArrayQueue from agrona or MpscArrayQueue from jctools . But neither of these queues preallocates objects in the way LMAX disruptor does. When I call ManyToOneConcurrentArrayQueue::offer or MpscArrayQueue::offer I transfer ownership of the object to the queue, and when I call ManyToOneConcurrentArrayQueue::poll or MpscArrayQueue::poll I take the ownership from them. It is a problem, since it forces me to have a separate object pool for recycling these objects to avoid garbage creation. It is obviously slower than to have preallocated array which always keeps an ownership of its contents (a la RingBuffer in LMAX disruptor package).

I wouldn't like to reinvent the wheel and build such a data structure myself, but I couldn't find an existing one either. I will appreciate any help if anybody came across such a structure already.

破坏者库包括一个EventPoller

It would be possible to use the LMAX disruptors RingBuffer implementation directly.

Potentially leveraging other parts of the project without starting the disruptor as a whole.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM