cameron314 / concurrentqueue

A fast multi-producer, multi-consumer lock-free concurrent queue for C++11
Other
9.86k stars 1.68k forks source link

Multi-producer single consumer model, consumption order and production is inconsistent #390

Open fxsts opened 3 months ago

fxsts commented 3 months ago

Multiple threads receive stock ticker data, store it in the queue, and a single thread takes out data from the queue for processing, and finds that it is not strictly in accordance with the order of consumption, and some stocks begin to consume after the close.

cameron314 commented 3 months ago

This is covered in the README. Order is only preserved between elements enqueued by a given producer.

fxsts commented 3 months ago

Can FIFO be guaranteed with one producer and one consumer? I've tried and it doesn't seem to work. Is there any configuration or overloading required?

cameron314 commented 3 months ago

With one producer FIFO is guaranteed. Can you share a counterexample?