-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add an AtomicCell abstraction #62577
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -271,6 +322,8 @@ cfg_if! { | |||
|
|||
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64}; | |||
|
|||
pub use crossbeam_utils::atomic::AtomicCell; |
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 don't get why you define the struct AtomicCell
above but then use it from the crossbeam_utils? Are they different? What is the purpose of including AtomicCell from crossbeam_utils here?
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.
In general, this code defines a unified set of structures related to multi-threadiness(?) with a caveat - the definitions are different for parallel_compiler
cfg.
If you expand the omitted lines in the diff, you can see that the pub struct AtomicCell<T: Copy>(Cell<T>);
(which is mainly a wrapper around Cell<T>
, which isn't really atomic nor should it be in single-threaded case) is defined manually in the #[cfg(not(parallel_compiler))]
branch.
Otherwise, if we build a parallel compiler, we just re-export crossbeam_utils::atomic::AtomicCell
instead.
@bors r+ |
📌 Commit 498bdc9 has been approved by |
Add an AtomicCell abstraction Split out from rust-lang#61923.
Rollup of 5 pull requests Successful merges: - #62577 (Add an AtomicCell abstraction) - #62585 (Make struct_tail normalize when possible) - #62604 (Handle errors during error recovery gracefully) - #62636 (rustbuild: Improve assert about building tools once) - #62651 (Make some rustc macros more hygienic) Failed merges: r? @ghost
Split out from #61923.