diff --git a/Cargo.toml b/Cargo.toml index b660a5c1..22958b22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,11 +51,11 @@ repository = "uuid-rs/uuid" default = ["std"] std = [] macro-diagnostics = ["private_uuid-macro-internal"] -v1 = [] +v1 = ["private_atomic"] v3 = ["md5"] v4 = ["rng"] v5 = ["sha1"] -v6 = [] +v6 = ["private_atomic"] v7 = ["rng"] v8 = [] js = ["private_getrandom", "private_getrandom/js"] @@ -134,6 +134,12 @@ version = "1.1.2" path = "macros" optional = true +[dependencies.private_atomic] +package = "atomic" +default-features = false +optional = true +version = "0.5" + [dev-dependencies.bincode] version = "1.0" diff --git a/src/timestamp.rs b/src/timestamp.rs index 7b52e49d..cb4db0bc 100644 --- a/src/timestamp.rs +++ b/src/timestamp.rs @@ -112,14 +112,14 @@ impl<'a, T: ClockSequence + ?Sized> ClockSequence for &'a T { } /// For features v1 and v1, constructs a `Context` struct which implements the `ClockSequence` trait -#[cfg(any(feature = "v1", feature = "v6", feature = "v7"))] +#[cfg(any(feature = "v1", feature = "v6"))] pub mod context { - use std::sync::atomic::{AtomicU16, Ordering}; + use private_atomic::{Atomic, Ordering}; /// A thread-safe, stateful context for the v1 generator to help ensure /// process-wide uniqueness. #[derive(Debug)] pub struct Context { - count: AtomicU16, + count: Atomic, } impl Context { @@ -133,7 +133,7 @@ pub mod context { /// process. pub const fn new(count: u16) -> Self { Self { - count: AtomicU16::new(count), + count: Atomic::::new(count), } } @@ -151,7 +151,7 @@ pub mod context { #[cfg(feature = "rng")] pub fn new_random() -> Self { Self { - count: AtomicU16::new(crate::rng::u16()), + count: Atomic::::new(crate::rng::u16()), } } }