max0x7ba / atomic_queue

C++ lockless queue.
MIT License
1.47k stars 176 forks source link

Docs: optimistic version "busy-waits when empty or full", and what does the other do? #25

Closed nunojpg closed 4 years ago

nunojpg commented 4 years ago

Something unclear to me while reading the README and also peeking at the code. So considering:

AtomicQueue - a fixed size ring-buffer for atomic elements. OptimistAtomicQueue - a faster fixed size ring-buffer for atomic elements which busy-waits when empty or full.

What does AtomicQueue do when empty or full?

max0x7ba commented 4 years ago

The difference between AtomicQueue and OptimistAtomicQueue is that

nunojpg commented 4 years ago

You have that well explained in the README.

So maybe the confusion is that that API only exists for those versions? I.e. AtomicQueue does not have push/pop, and OptimisticAtomicQueue does not have try_*?

Because from the documentation I understood both version have all the 4 methods.

max0x7ba commented 4 years ago

Because from the documentation I understood both version have all the 4 methods.

You are right, AtomicQueue class provides both versions, with and without try_. It is the usage that determines whether the queue is used in optimistic fashion, there is no OptimistAtomicQueue class. In some cases you may want push and try_pop, i.e. optimistic producer, but pessimistic consumer.

nunojpg commented 4 years ago

Ok, thanks!