Skip to content

Commit

Permalink
Merge #262
Browse files Browse the repository at this point in the history
262: Move AtomicCell into crossbeam-utils r=stjepang a=stjepang

At this point, I feel pretty confident about the current state of `AtomicCell` in the sense that we probably won't make any breaking changes to its public API in the future.

It's also a reasonably small utility without dependencies that deserves living in `crossbeam-utils`. The Rust compiler would like to use it in place of its `LockCell`, and already has `crossbeam-utils` whitelisted. See [this PR](rust-lang/rust#56614 (comment)).

Let's move `AtomicCell` into `crossbeam-utils` so that people can use it without depending on whole `crossbeam`.

Co-authored-by: Stjepan Glavina <stjepang@gmail.com>
  • Loading branch information
bors[bot] and Stjepan Glavina committed Dec 11, 2018
2 parents a3252af + 7afa01a commit 4d47cd2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
44 changes: 22 additions & 22 deletions src/atomic_cell.rs → crossbeam-utils/src/atomic/atomic_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<T> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(7);
/// ```
Expand All @@ -48,7 +48,7 @@ impl<T> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let mut a = AtomicCell::new(7);
/// *a.get_mut() += 1;
Expand All @@ -64,7 +64,7 @@ impl<T> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let mut a = AtomicCell::new(7);
/// let v = a.into_inner();
Expand All @@ -83,7 +83,7 @@ impl<T> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// // This type is internally represented as `AtomicUsize` so we can just use atomic
/// // operations provided by it.
Expand Down Expand Up @@ -112,7 +112,7 @@ impl<T> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(7);
///
Expand All @@ -135,7 +135,7 @@ impl<T> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(7);
///
Expand All @@ -154,7 +154,7 @@ impl<T: Copy> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(7);
///
Expand All @@ -174,7 +174,7 @@ impl<T: Copy + Eq> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(1);
///
Expand All @@ -199,7 +199,7 @@ impl<T: Copy + Eq> AtomicCell<T> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(1);
///
Expand Down Expand Up @@ -239,7 +239,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand Down Expand Up @@ -267,7 +267,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand All @@ -293,7 +293,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand All @@ -319,7 +319,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand All @@ -345,7 +345,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand Down Expand Up @@ -376,7 +376,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand All @@ -396,7 +396,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand All @@ -414,7 +414,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand All @@ -432,7 +432,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand All @@ -450,7 +450,7 @@ macro_rules! impl_arithmetic {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
#[doc = $example]
///
Expand Down Expand Up @@ -505,7 +505,7 @@ impl AtomicCell<bool> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(true);
///
Expand All @@ -526,7 +526,7 @@ impl AtomicCell<bool> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(false);
///
Expand All @@ -547,7 +547,7 @@ impl AtomicCell<bool> {
/// # Examples
///
/// ```
/// use crossbeam::atomic::AtomicCell;
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(true);
///
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-utils/src/atomic/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Additional utilities for atomics.
mod atomic_cell;
mod consume;

pub use self::atomic_cell::AtomicCell;
pub use self::consume::AtomicConsume;
4 changes: 2 additions & 2 deletions tests/atomic_cell.rs → crossbeam-utils/tests/atomic_cell.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
extern crate crossbeam;
extern crate crossbeam_utils;

use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;

use crossbeam::atomic::AtomicCell;
use crossbeam_utils::atomic::AtomicCell;

#[test]
fn is_lock_free() {
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ mod _epoch {
pub use _epoch::crossbeam_epoch as epoch;

mod arc_cell;
mod atomic_cell;

extern crate crossbeam_utils;

/// Additional utilities for atomics.
pub mod atomic {
pub use arc_cell::ArcCell;
pub use atomic_cell::AtomicCell;
pub use crossbeam_utils::atomic::AtomicCell;
pub use crossbeam_utils::atomic::AtomicConsume;
}

Expand Down

0 comments on commit 4d47cd2

Please sign in to comment.