Skip to content

Add an AtomicCell abstraction - #62577

Merged
bors merged 1 commit into
rust-lang:masterfrom
Zoxc:atomic-cell
Jul 13, 2019
Merged

Add an AtomicCell abstraction#62577
bors merged 1 commit into
rust-lang:masterfrom
Zoxc:atomic-cell

Conversation

@Zoxc

@ZoxcZoxc commented Jul 11, 2019

Copy link
Copy Markdown
Contributor

Split out from #61923.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 11, 2019

pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};

pub use crossbeam_utils::atomic::AtomicCell;

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor

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.

@matthewjasper

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jul 11, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 498bdc9 has been approved by matthewjasper

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 11, 2019
Centril added a commit to Centril/rust that referenced this pull request Jul 13, 2019
@CentrilCentril mentioned this pull request Jul 13, 2019
bors added a commit that referenced this pull request Jul 13, 2019
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
@bors
bors merged commit 498bdc9 into rust-lang:masterJul 13, 2019
@jyn514jyn514 mentioned this pull request Mar 29, 2021
6 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@Zoxc@rust-highfive@matthewjasper@bors@hellow554@Xanewok