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

Explain the atomic orderings used in race #175

Merged
merged 2 commits into from Mar 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/race.rs
Expand Up @@ -10,13 +10,14 @@
//!
//! All types in this module use `Acquire` and `Release`
//! [atomic orderings](Ordering) for all their operations. While this is not
//! strictly necessary, it is useful for users as it allows them to be certain
//! that after `get` or `get_or_init` returns on one thread, any side-effects
//! caused by the setter thread prior to them calling `set` or `get_or_init`
//! will be made visible to that thread; without it, it's possible for it to
//! appear as if they haven't happened yet from the getter thread's perspective.
//! This is an acceptable tradeoff to make since `Acquire` and `Release` have
//! very little performance overhead on most architectures versus `Relaxed`.
//! strictly necessary for types other than `OnceBox`, it is useful for users as
//! it allows them to be certain that after `get` or `get_or_init` returns on
//! one thread, any side-effects caused by the setter thread prior to them
//! calling `set` or `get_or_init` will be made visible to that thread; without
//! it, it's possible for it to appear as if they haven't happened yet from the
//! getter thread's perspective. This is an acceptable tradeoff to make since
//! `Acquire` and `Release` have very little performance overhead on most
//! architectures versus `Relaxed`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Bonus points if you can add a "litmus test" example here!


#[cfg(feature = "atomic-polyfill")]
use atomic_polyfill as atomic;
Expand Down