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

Add an AtomicCell abstraction #62577

Merged
merged 1 commit into from Jul 13, 2019

Conversation

@Zoxc
Copy link
Contributor

commented Jul 11, 2019

Split out from #61923.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jul 11, 2019

r? @matthewjasper

(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;

This comment has been minimized.

Copy link
@hellow554

hellow554 Jul 11, 2019

Contributor

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?

This comment has been minimized.

Copy link
@Xanewok

Xanewok Jul 12, 2019

Member

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

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

📌 Commit 498bdc9 has been approved by matthewjasper

Centril added a commit to Centril/rust that referenced this pull request Jul 13, 2019

Rollup merge of rust-lang#62577 - Zoxc:atomic-cell, r=matthewjasper
Add an AtomicCell abstraction

Split out from rust-lang#61923.

bors added a commit that referenced this pull request Jul 13, 2019

Auto merge of #62659 - Centril:rollup-90oz643, r=Centril
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:master Jul 13, 2019

3 checks passed

pr Build #20190711.2 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.