Skip to content

Commit

Permalink
Feature gate spinlock in shared future
Browse files Browse the repository at this point in the history
  • Loading branch information
adavis628 committed Dec 22, 2024
1 parent af51ae2 commit 7b85ccb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions futures-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"] }
Expand Down
8 changes: 4 additions & 4 deletions futures-util/src/future/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: ?Sized> FutureExt for T where T: Future {}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Self>
where
Self: Sized,
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions futures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7b85ccb

Please sign in to comment.