diff --git a/futures-util/Cargo.toml b/futures-util/Cargo.toml index f4d5466f1..2ecd6f54b 100644 --- a/futures-util/Cargo.toml +++ b/futures-util/Cargo.toml @@ -22,6 +22,7 @@ sink = ["futures-sink"] io = ["std", "futures-io", "memchr"] channel = ["std", "futures-channel"] portable-atomic = ["futures-core/portable-atomic"] +spin = ["dep:spin"] # Unstable features # These features are outside of the normal semver guarantees and require the @@ -43,9 +44,7 @@ futures_01 = { version = "0.1.25", optional = true, package = "futures" } tokio-io = { version = "0.1.9", optional = true } pin-utils = "0.1.0" pin-project-lite = "0.2.6" - -[target.'cfg(target_has_atomic = "8")'.dependencies] -spin = "0.9.8" +spin = { version = "0.9.8", optional = true } [dev-dependencies] futures = { path = "../futures", features = ["async-await", "thread-pool"] } diff --git a/futures-util/src/future/future/mod.rs b/futures-util/src/future/future/mod.rs index ee757eb0a..e0f408739 100644 --- a/futures-util/src/future/future/mod.rs +++ b/futures-util/src/future/future/mod.rs @@ -107,9 +107,9 @@ mod remote_handle; #[cfg(feature = "std")] pub use self::remote_handle::{Remote, RemoteHandle}; -#[cfg(all(feature = "alloc", target_has_atomic = "8"))] +#[cfg(any(feature = "std", feature = "spin"))] mod shared; -#[cfg(all(feature = "alloc", target_has_atomic = "8"))] +#[cfg(any(feature = "std", feature = "spin"))] pub use self::shared::{Shared, WeakShared}; impl FutureExt for T where T: Future {} @@ -440,7 +440,7 @@ pub trait FutureExt: Future { /// into a cloneable future. It enables a future to be polled by multiple /// threads. /// - /// This method is only available when the `std` feature of this + /// This method is only available when the `std` or 'spin' feature of this /// library is activated, and it is activated by default. /// /// # Examples @@ -474,7 +474,7 @@ pub trait FutureExt: Future { /// join_handle.join().unwrap(); /// # }); /// ``` - #[cfg(all(feature = "alloc", target_has_atomic = "8"))] + #[cfg(any(feature = "std", feature = "spin"))] fn shared(self) -> Shared where Self: Sized, diff --git a/futures-util/src/future/mod.rs b/futures-util/src/future/mod.rs index e3ca85f6f..ce7182905 100644 --- a/futures-util/src/future/mod.rs +++ b/futures-util/src/future/mod.rs @@ -35,7 +35,7 @@ pub use self::future::CatchUnwind; #[cfg(feature = "std")] pub use self::future::{Remote, RemoteHandle}; -#[cfg(all(feature = "alloc", target_has_atomic = "8"))] +#[cfg(any(feature = "std", feature = "spin"))] pub use self::future::{Shared, WeakShared}; mod try_future; diff --git a/futures/Cargo.toml b/futures/Cargo.toml index 84edf9000..c56228866 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -40,6 +40,7 @@ compat = ["std", "futures-util/compat"] io-compat = ["compat", "futures-util/io-compat"] executor = ["std", "futures-executor/std"] thread-pool = ["executor", "futures-executor/thread-pool"] +spin = ["futures-util/spin"] # Unstable features # These features are outside of the normal semver guarantees and require the