Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nunojpg opened this issue Sep 8, 2020 · 4 comments

Comments

@nunojpg
Copy link

nunojpg commented Sep 8, 2020

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
Copy link
Owner

max0x7ba commented Sep 9, 2020

The difference between AtomicQueue and OptimistAtomicQueue is that

  • AtomicQueue uses try_push/try_pop which return false when the queue is full/empty.
  • OptimistAtomicQueue uses push/pop which busy wait when the queue is full/empty.

@nunojpg
Copy link
Author

nunojpg commented Sep 9, 2020

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
Copy link
Owner

max0x7ba commented Sep 9, 2020

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
Copy link
Author

nunojpg commented Sep 9, 2020

Ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants