简体   繁体   中英

Parallel Producers in Disruptor (Ring buffer) (used in log4j2)

So I understand the purpose of the LMX Disruptor algorithm (used in log4j2). My question is why can't producers just write to multiple slots in the ring buffer in parallel. Why do we need a write pointer, since next sequence generator is assigning incrementing numbers to different processes. I understand that serialising writes (and write pointers), helps consumers to know up to which slot can be read. Is that the only reason?

How would you prevent multiple producers from writing into the same slot?

Asuming you are using the MultiProducerSequencer , a single producer can write into multiple slots by calling next(int) and multiple parallel producers can obviously write into slots in parallel either in single slots ( next() ) or batches ( next(int) ).

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