-
Notifications
You must be signed in to change notification settings - Fork 13k
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
atomic ordering docs #53106
atomic ordering docs #53106
Conversation
r? @TimNN (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like these clarifications! 👍
Another thing we could do is specify which orderings are valid for each operation (in the docs of each of the methods like store
, load
, swap
, etc.).
@@ -384,9 +419,11 @@ impl AtomicBool { | |||
/// was updated. | |||
/// | |||
/// `compare_and_swap` also takes an [`Ordering`] argument which describes the memory | |||
/// ordering of this operation. | |||
/// ordering of this operation. Notice that even when using [`AcqRel`], the operation | |||
/// might fail and hence just perform an `Acquire` load, but not have `Release` semantics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also applies to compare_exchange
and compare_exchange_weak
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it does not. Those have a separate argument for the ordering used in case of failure.
Hm... that would make for quite a large diff, and it is already stated in the |
src/libcore/sync/atomic.rs
Outdated
/// | ||
/// Corresponds to LLVM's [`Release`] ordering. | ||
/// | ||
/// [`Release`]: http://llvm.org/docs/Atomics.html#release | ||
/// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change these links to HTTPS as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/libcore/sync/atomic.rs
Outdated
/// | ||
/// [`Ordering`]: enum.Ordering.html | ||
/// [`Ordering`]: enum.Ordering.html#variant.AcqRel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label should be [`AcqRel`]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
Done. I hope I didn't miss any, nor screw up one of them.^^ |
@stjepang: Since you already commented, and are much more familiar with the subject the I am, I think, could you review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read through the whole set of changes and everything seems correct and clear. 👍
📌 Commit 6a018a0 has been approved by |
atomic ordering docs Discussion in rust-lang/rfcs#2503 revealed that this could be improved. I hope this helps.
Rollup of 15 pull requests Successful merges: - #52773 (Avoid unnecessary pattern matching against Option and Result) - #53082 (Fix doc link (again)) - #53094 (Automatically expand section if url id point to one of its component) - #53106 (atomic ordering docs) - #53110 (Account for --remap-path-prefix in save-analysis) - #53116 (NetBSD: fix signedess of char) - #53179 (Whitelist wasm32 simd128 target feature) - #53183 (Suggest comma when missing in macro call) - #53207 (Add individual docs for rotate_{left, right}) - #53211 ([nll] enable feature(nll) on various crates for bootstrap) - #53214 ([nll] enable feature(nll) on various crates for bootstrap: part 2) - #53215 (Slightly refactor syntax_ext/format) - #53217 (inline some short functions) - #53219 ([nll] enable feature(nll) on various crates for bootstrap: part 3) - #53222 (A few cleanups for rustc_target)
Discussion in rust-lang/rfcs#2503 revealed that this could be improved. I hope this helps.