Skip to content

Commit dd664a3

Browse files
committed
Move AtomicWaker from futures-core to futures-task
1 parent 86e3d1b commit dd664a3

File tree

9 files changed

+25
-17
lines changed

9 files changed

+25
-17
lines changed

futures-channel/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ cfg-target-has-atomic = ["futures-core-preview/cfg-target-has-atomic"]
2828

2929
[dependencies]
3030
futures-core-preview = { path = "../futures-core", version = "=0.3.0-alpha.19", default-features = false }
31+
futures-task-preview = { path = "../futures-task", version = "=0.3.0-alpha.19", default-features = false }
3132
futures-sink-preview = { path = "../futures-sink", version = "=0.3.0-alpha.19", default-features = false, optional = true }
3233

3334
[dev-dependencies]

futures-channel/src/mpsc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
use futures_core::stream::{FusedStream, Stream};
8282
use futures_core::task::{Context, Poll, Waker};
83-
use futures_core::task::__internal::AtomicWaker;
83+
use futures_task::AtomicWaker;
8484
use std::fmt;
8585
use std::pin::Pin;
8686
use std::sync::{Arc, Mutex};

futures-core/src/task/poll.rs renamed to futures-core/src/task.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Task notification.
2+
3+
pub use core::task::{Context, Poll, Waker, RawWaker, RawWakerVTable};
4+
15
/// Extracts the successful type of a `Poll<T>`.
26
///
37
/// This macro bakes in propagation of `Pending` signals by returning early.

futures-core/src/task/__internal/mod.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

futures-core/src/task/mod.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

futures-task/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ default = ["std"]
1919
std = ["alloc"]
2020
alloc = []
2121

22+
# Unstable features
23+
# These features are outside of the normal semver guarantees and require the
24+
# `unstable` feature as an explicit opt-in to unstable API.
25+
unstable = []
26+
cfg-target-has-atomic = []
27+
2228
[dependencies]
2329
futures-core-preview = { path = "../futures-core", version = "=0.3.0-alpha.19" }

futures-core/src/task/__internal/atomic_waker.rs renamed to futures-task/src/atomic_waker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use core::fmt;
21
use core::cell::UnsafeCell;
2+
use core::fmt;
33
use core::sync::atomic::AtomicUsize;
44
use core::sync::atomic::Ordering::{Acquire, Release, AcqRel};
5-
use crate::task::Waker;
5+
use core::task::Waker;
66

77
/// A synchronization primitive for task wakeup.
88
///

futures-task/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Tools for working with tasks.
22
3+
#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))]
4+
35
#![cfg_attr(not(feature = "std"), no_std)]
46

57
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
@@ -11,10 +13,18 @@
1113

1214
#![doc(html_root_url = "https://docs.rs/futures-task-preview/0.3.0-alpha.19")]
1315

16+
#[cfg(all(feature = "cfg-target-has-atomic", not(feature = "unstable")))]
17+
compile_error!("The `cfg-target-has-atomic` feature requires the `unstable` feature as an explicit opt-in to unstable features");
18+
1419
#[cfg(feature = "alloc")]
1520
extern crate alloc;
1621

1722
mod spawn;
1823
pub use crate::spawn::{Spawn, SpawnError, LocalSpawn};
1924

25+
#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
26+
mod atomic_waker;
27+
#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
28+
pub use crate::atomic_waker::AtomicWaker;
29+
2030
pub use futures_core::future::{FutureObj, LocalFutureObj};

futures-util/src/task/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cfg_target_has_atomic! {
1616
#[cfg(feature = "alloc")]
1717
pub use self::waker_ref::{waker_ref, WakerRef};
1818

19-
pub use futures_core::task::__internal::AtomicWaker;
19+
pub use futures_task::AtomicWaker;
2020
}
2121

2222
mod noop_waker;

0 commit comments

Comments
 (0)