Skip to content

Commit

Permalink
utils: Move atomic module behind atomic feature
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Dec 8, 2024
1 parent 814fdc6 commit 2bf894f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ crossbeam-channel = { version = "0.5.10", path = "crossbeam-channel", default-fe
crossbeam-deque = { version = "0.8.4", path = "crossbeam-deque", default-features = false, optional = true }
crossbeam-epoch = { version = "0.9.17", path = "crossbeam-epoch", default-features = false, optional = true }
crossbeam-queue = { version = "0.3.10", path = "crossbeam-queue", default-features = false, optional = true }
crossbeam-utils = { version = "0.8.18", path = "crossbeam-utils", default-features = false }
crossbeam-utils = { version = "0.8.18", path = "crossbeam-utils", default-features = false, features = ["atomic"] }

[dev-dependencies]
rand = "0.8"
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ default = ["std"]
std = ["crossbeam-utils/std"]

[dependencies]
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false }
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false, features = ["atomic"] }

[dev-dependencies]
num_cpus = "1.13.0"
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-epoch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ alloc = []
loom = ["loom-crate", "crossbeam-utils/loom"]

[dependencies]
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false }
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false, features = ["atomic"] }

# Enable the use of loom for concurrency testing.
#
Expand Down
6 changes: 1 addition & 5 deletions crossbeam-epoch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ mod primitive {
}
}
pub(crate) mod sync {
pub(crate) mod atomic {
pub(crate) use core::sync::atomic::{
compiler_fence, fence, AtomicPtr, AtomicUsize, Ordering,
};
}
pub(crate) use core::sync::atomic;
#[cfg(feature = "alloc")]
pub(crate) use alloc::sync::Arc;
}
Expand Down
6 changes: 6 additions & 0 deletions crossbeam-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ description = "Utilities for concurrent programming"
keywords = ["scoped", "thread", "atomic", "cache"]
categories = ["algorithms", "concurrency", "data-structures", "no-std"]

[package.metadata.docs.rs]
all-features = true

[features]
default = ["std"]

# Enable to use APIs that require `std`.
# This is enabled by default.
std = []

# Enable `atomic` module.
atomic = []

[dependencies]

# Enable the use of loom for concurrency testing.
Expand Down
21 changes: 4 additions & 17 deletions crossbeam-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
))]
#![warn(missing_docs, unsafe_op_in_unsafe_fn)]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(feature = "std")]
extern crate std;
Expand Down Expand Up @@ -67,28 +68,14 @@ mod primitive {
pub(crate) use core::hint::spin_loop;
}
pub(crate) mod sync {
pub(crate) mod atomic {
pub(crate) use core::sync::atomic::{compiler_fence, Ordering};
#[cfg(not(crossbeam_no_atomic))]
pub(crate) use core::sync::atomic::{
AtomicBool, AtomicI16, AtomicI8, AtomicIsize, AtomicU16, AtomicU8, AtomicUsize,
};
#[cfg(not(crossbeam_no_atomic))]
#[cfg(any(target_has_atomic = "32", not(target_pointer_width = "16")))]
pub(crate) use core::sync::atomic::{AtomicI32, AtomicU32};
#[cfg(not(crossbeam_no_atomic))]
#[cfg(any(
target_has_atomic = "64",
not(any(target_pointer_width = "16", target_pointer_width = "32")),
))]
pub(crate) use core::sync::atomic::{AtomicI64, AtomicU64};
}

pub(crate) use core::sync::atomic;
#[cfg(feature = "std")]
pub(crate) use std::sync::{Arc, Condvar, Mutex};
}
}

#[cfg(feature = "atomic")]
#[cfg_attr(docsrs, doc(cfg(feature = "atomic")))]
pub mod atomic;

mod cache_padded;
Expand Down

0 comments on commit 2bf894f

Please sign in to comment.