Skip to content

Commit 8021bb8

Browse files
committed
Move AtomicWaker to futures-core
... so `AtomicWaker` could be used inside `futures-channel`. `AtomicWaker` is still accessible to users only from `futures-util`.
1 parent cbcf1fe commit 8021bb8

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

futures-core/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
cargo-features = ["rename-dependency"]
2+
13
[package]
24
name = "futures-core-preview"
35
edition = "2018"
@@ -17,6 +19,10 @@ name = "futures_core"
1719
[features]
1820
default = ["std"]
1921
std = ["either/use_std"]
22+
nightly = []
2023

2124
[dependencies]
2225
either = { version = "1.4", default-features = false, optional = true }
26+
27+
[dev-dependencies]
28+
futures-preview = { path = "../futures", version = "0.3.0-alpha.9" }

futures-core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Core traits and types for asynchronous operations in Rust.
22
33
#![feature(pin, arbitrary_self_types, futures_api)]
4+
#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))]
45

56
#![cfg_attr(not(feature = "std"), no_std)]
67

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

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

77
/// A synchronization primitive for task wakeup.
88
///
@@ -170,8 +170,9 @@ impl AtomicWaker {
170170
///
171171
/// ```
172172
/// #![feature(pin, arbitrary_self_types, futures_api)]
173-
/// use futures::future::Future;
174-
/// use futures::task::{LocalWaker, Poll, AtomicWaker};
173+
/// use futures_core::future::Future;
174+
/// use futures_core::task::__internal::AtomicWaker;
175+
/// use futures_core::task::{LocalWaker, Poll};
175176
/// use std::sync::atomic::AtomicBool;
176177
/// use std::sync::atomic::Ordering::SeqCst;
177178
/// use std::pin::Pin;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[cfg_attr(
2+
feature = "nightly",
3+
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
4+
)]
5+
mod atomic_waker;
6+
#[cfg_attr(
7+
feature = "nightly",
8+
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
9+
)]
10+
pub use self::atomic_waker::AtomicWaker;

futures-core/src/task/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Task notification.
22
33
mod spawn;
4+
#[doc(hidden)]
5+
pub mod __internal;
46
pub use self::spawn::{Spawn, LocalSpawn, SpawnError};
57

68
pub use core::task::{Poll, Waker, LocalWaker, UnsafeWake};

futures-util/src/task/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,4 @@ pub use self::local_waker_ref::{local_waker_ref, local_waker_ref_from_nonlocal,
1515
feature = "nightly",
1616
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
1717
)]
18-
mod atomic_waker;
19-
#[cfg_attr(
20-
feature = "nightly",
21-
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
22-
)]
23-
pub use self::atomic_waker::AtomicWaker;
18+
pub use futures_core::task::__internal::AtomicWaker;

0 commit comments

Comments
 (0)