From aebf1926fd770971cf9deca45e6e8e5aaf15d53d Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 5 Nov 2019 18:01:35 +0900 Subject: [PATCH] Revert "Move AtomicWaker from futures-core to futures-task" This reverts commit dd664a39a7d3b384c30ecc436cd8279b9c7713fd. --- futures-channel/Cargo.toml | 5 ++--- futures-channel/src/mpsc/mod.rs | 2 +- .../src/task/__internal}/atomic_waker.rs | 0 futures-core/src/task/__internal/mod.rs | 4 ++++ futures-core/src/task/mod.rs | 9 +++++++++ futures-core/src/{task.rs => task/poll.rs} | 4 ---- futures-task/Cargo.toml | 6 ------ futures-task/src/lib.rs | 10 ---------- futures-util/Cargo.toml | 4 ++-- futures-util/src/stream/futures_unordered/mod.rs | 3 ++- futures-util/src/task/mod.rs | 2 +- futures/Cargo.toml | 4 ++-- 12 files changed, 23 insertions(+), 30 deletions(-) rename {futures-task/src => futures-core/src/task/__internal}/atomic_waker.rs (100%) create mode 100644 futures-core/src/task/__internal/mod.rs create mode 100644 futures-core/src/task/mod.rs rename futures-core/src/{task.rs => task/poll.rs} (80%) diff --git a/futures-channel/Cargo.toml b/futures-channel/Cargo.toml index cc6a68db40..d45d946c84 100644 --- a/futures-channel/Cargo.toml +++ b/futures-channel/Cargo.toml @@ -23,12 +23,11 @@ sink = ["futures-sink-preview"] # Unstable features # These features are outside of the normal semver guarantees and require the # `unstable` feature as an explicit opt-in to unstable API. -unstable = ["futures-core-preview/unstable", "futures-task-preview/unstable"] -cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic", "futures-task-preview/cfg-target-has-atomic"] +unstable = ["futures-core-preview/unstable"] +cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic"] [dependencies] futures-core-preview = { path = "../futures-core", version = "=0.3.0-alpha.19", default-features = false } -futures-task-preview = { path = "../futures-task", version = "=0.3.0-alpha.19", default-features = false } futures-sink-preview = { path = "../futures-sink", version = "=0.3.0-alpha.19", default-features = false, optional = true } [dev-dependencies] diff --git a/futures-channel/src/mpsc/mod.rs b/futures-channel/src/mpsc/mod.rs index f731ed3bc3..e9961e522c 100644 --- a/futures-channel/src/mpsc/mod.rs +++ b/futures-channel/src/mpsc/mod.rs @@ -80,7 +80,7 @@ use futures_core::stream::{FusedStream, Stream}; use futures_core::task::{Context, Poll, Waker}; -use futures_task::AtomicWaker; +use futures_core::task::__internal::AtomicWaker; use std::fmt; use std::pin::Pin; use std::sync::{Arc, Mutex}; diff --git a/futures-task/src/atomic_waker.rs b/futures-core/src/task/__internal/atomic_waker.rs similarity index 100% rename from futures-task/src/atomic_waker.rs rename to futures-core/src/task/__internal/atomic_waker.rs diff --git a/futures-core/src/task/__internal/mod.rs b/futures-core/src/task/__internal/mod.rs new file mode 100644 index 0000000000..77e3678075 --- /dev/null +++ b/futures-core/src/task/__internal/mod.rs @@ -0,0 +1,4 @@ +#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))] +mod atomic_waker; +#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))] +pub use self::atomic_waker::AtomicWaker; diff --git a/futures-core/src/task/mod.rs b/futures-core/src/task/mod.rs new file mode 100644 index 0000000000..362b376e04 --- /dev/null +++ b/futures-core/src/task/mod.rs @@ -0,0 +1,9 @@ +//! Task notification. + +#[macro_use] +mod poll; + +#[doc(hidden)] +pub mod __internal; + +pub use core::task::{Context, Poll, Waker, RawWaker, RawWakerVTable}; diff --git a/futures-core/src/task.rs b/futures-core/src/task/poll.rs similarity index 80% rename from futures-core/src/task.rs rename to futures-core/src/task/poll.rs index 3b7aa04114..fc61683e76 100644 --- a/futures-core/src/task.rs +++ b/futures-core/src/task/poll.rs @@ -1,7 +1,3 @@ -//! Task notification. - -pub use core::task::{Context, Poll, Waker, RawWaker, RawWakerVTable}; - /// Extracts the successful type of a `Poll`. /// /// This macro bakes in propagation of `Pending` signals by returning early. diff --git a/futures-task/Cargo.toml b/futures-task/Cargo.toml index 356fb6f6fa..c761d59c72 100644 --- a/futures-task/Cargo.toml +++ b/futures-task/Cargo.toml @@ -19,12 +19,6 @@ default = ["std"] std = ["alloc"] alloc = [] -# Unstable features -# These features are outside of the normal semver guarantees and require the -# `unstable` feature as an explicit opt-in to unstable API. -unstable = [] -cfg-target-has-atomic = [] - [dependencies] [dev-dependencies] diff --git a/futures-task/src/lib.rs b/futures-task/src/lib.rs index 7efc685e59..1c6ef33726 100644 --- a/futures-task/src/lib.rs +++ b/futures-task/src/lib.rs @@ -1,7 +1,5 @@ //! Tools for working with tasks. -#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))] - #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)] @@ -13,9 +11,6 @@ #![doc(html_root_url = "https://docs.rs/futures-task-preview/0.3.0-alpha.19")] -#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "unstable")))] -compile_error!("The `cfg-target-has-atomic` feature requires the `unstable` feature as an explicit opt-in to unstable features"); - #[cfg(feature = "alloc")] extern crate alloc; @@ -30,11 +25,6 @@ mod spawn; pub use crate::spawn::{Spawn, SpawnError, LocalSpawn}; cfg_target_has_atomic! { - #[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))] - mod atomic_waker; - #[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))] - pub use crate::atomic_waker::AtomicWaker; - #[cfg(feature = "alloc")] mod arc_wake; #[cfg(feature = "alloc")] diff --git a/futures-util/Cargo.toml b/futures-util/Cargo.toml index 93e9746710..e49dc55f59 100644 --- a/futures-util/Cargo.toml +++ b/futures-util/Cargo.toml @@ -29,8 +29,8 @@ channel = ["std", "futures-channel-preview"] # Unstable features # These features are outside of the normal semver guarantees and require the # `unstable` feature as an explicit opt-in to unstable API. -unstable = ["futures-core-preview/unstable", "futures-task-preview/unstable"] -cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic", "futures-task-preview/cfg-target-has-atomic"] +unstable = ["futures-core-preview/unstable"] +cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic"] bilock = [] read-initializer = ["io", "futures-io-preview/read-initializer", "futures-io-preview/unstable"] diff --git a/futures-util/src/stream/futures_unordered/mod.rs b/futures-util/src/stream/futures_unordered/mod.rs index 9be98b91ad..ff4efa8321 100644 --- a/futures-util/src/stream/futures_unordered/mod.rs +++ b/futures-util/src/stream/futures_unordered/mod.rs @@ -6,7 +6,8 @@ use futures_core::future::Future; use futures_core::stream::{FusedStream, Stream}; use futures_core::task::{Context, Poll}; -use futures_task::{FutureObj, LocalFutureObj, AtomicWaker, Spawn, LocalSpawn, SpawnError}; +use futures_task::{FutureObj, LocalFutureObj, Spawn, LocalSpawn, SpawnError}; +use crate::task::AtomicWaker; use core::cell::UnsafeCell; use core::fmt::{self, Debug}; use core::iter::FromIterator; diff --git a/futures-util/src/task/mod.rs b/futures-util/src/task/mod.rs index 1a1d1cab30..fb3b7adacd 100644 --- a/futures-util/src/task/mod.rs +++ b/futures-util/src/task/mod.rs @@ -10,7 +10,7 @@ cfg_target_has_atomic! { #[cfg(feature = "alloc")] pub use futures_task::{waker_ref, WakerRef}; - pub use futures_task::AtomicWaker; + pub use futures_core::task::__internal::AtomicWaker; } mod spawn; diff --git a/futures/Cargo.toml b/futures/Cargo.toml index 7da1cdb651..6c1b0afa7e 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -48,8 +48,8 @@ thread-pool = ["futures-executor-preview/thread-pool"] # Unstable features # These features are outside of the normal semver guarantees and require the # `unstable` feature as an explicit opt-in to unstable API. -unstable = ["futures-core-preview/unstable", "futures-task-preview/unstable", "futures-channel-preview/unstable", "futures-io-preview/unstable", "futures-util-preview/unstable"] -cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic", "futures-task-preview/cfg-target-has-atomic", "futures-channel-preview/cfg-target-has-atomic", "futures-util-preview/cfg-target-has-atomic"] +unstable = ["futures-core-preview/unstable", "futures-channel-preview/unstable", "futures-io-preview/unstable", "futures-util-preview/unstable"] +cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic", "futures-channel-preview/cfg-target-has-atomic", "futures-util-preview/cfg-target-has-atomic"] bilock = ["futures-util-preview/bilock"] read-initializer = ["futures-io-preview/read-initializer", "futures-util-preview/read-initializer"]