Skip to content

Commit 421d8f3

Browse files
committed
Move other task utils from futures-core to futures-task
1 parent dd664a3 commit 421d8f3

File tree

6 files changed

+43
-18
lines changed

6 files changed

+43
-18
lines changed
File renamed without changes.

futures-task/src/lib.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,42 @@ compile_error!("The `cfg-target-has-atomic` feature requires the `unstable` feat
1919
#[cfg(feature = "alloc")]
2020
extern crate alloc;
2121

22+
macro_rules! cfg_target_has_atomic {
23+
($($item:item)*) => {$(
24+
#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
25+
$item
26+
)*};
27+
}
28+
2229
mod spawn;
2330
pub use crate::spawn::{Spawn, SpawnError, LocalSpawn};
2431

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;
32+
cfg_target_has_atomic! {
33+
#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
34+
mod atomic_waker;
35+
#[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
36+
pub use crate::atomic_waker::AtomicWaker;
37+
38+
#[cfg(feature = "alloc")]
39+
mod arc_wake;
40+
#[cfg(feature = "alloc")]
41+
pub use crate::arc_wake::ArcWake;
42+
43+
#[cfg(feature = "alloc")]
44+
mod waker;
45+
#[cfg(feature = "alloc")]
46+
pub use crate::waker::waker;
47+
48+
#[cfg(feature = "alloc")]
49+
mod waker_ref;
50+
#[cfg(feature = "alloc")]
51+
pub use crate::waker_ref::{waker_ref, WakerRef};
52+
}
53+
54+
mod noop_waker;
55+
pub use crate::noop_waker::noop_waker;
56+
#[cfg(feature = "std")]
57+
pub use crate::noop_waker::noop_waker_ref;
2958

3059
pub use futures_core::future::{FutureObj, LocalFutureObj};
60+
pub use futures_core::task::{Context, Poll, Waker, RawWaker, RawWakerVTable};

futures-util/src/task/noop_waker.rs renamed to futures-task/src/noop_waker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Utilities for creating zero-cost wakers that don't do anything.
2+
23
use futures_core::task::{RawWaker, RawWakerVTable, Waker};
34
use core::ptr::null;
45
#[cfg(feature = "std")]
File renamed without changes.
File renamed without changes.

futures-util/src/task/mod.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,24 @@
22
33
cfg_target_has_atomic! {
44
#[cfg(feature = "alloc")]
5-
mod arc_wake;
6-
#[cfg(feature = "alloc")]
7-
pub use self::arc_wake::ArcWake;
5+
pub use futures_task::ArcWake;
86

97
#[cfg(feature = "alloc")]
10-
mod waker;
11-
#[cfg(feature = "alloc")]
12-
pub use self::waker::waker;
8+
pub use futures_task::waker;
139

1410
#[cfg(feature = "alloc")]
15-
mod waker_ref;
16-
#[cfg(feature = "alloc")]
17-
pub use self::waker_ref::{waker_ref, WakerRef};
11+
pub use futures_task::{waker_ref, WakerRef};
1812

1913
pub use futures_task::AtomicWaker;
2014
}
2115

22-
mod noop_waker;
23-
pub use self::noop_waker::noop_waker;
24-
#[cfg(feature = "std")]
25-
pub use self::noop_waker::noop_waker_ref;
26-
2716
mod spawn;
2817
pub use self::spawn::{SpawnExt, LocalSpawnExt};
2918

3019
pub use futures_core::task::{Context, Poll, Waker, RawWaker, RawWakerVTable};
20+
3121
pub use futures_task::{Spawn, LocalSpawn, SpawnError};
22+
23+
pub use futures_task::noop_waker;
24+
#[cfg(feature = "std")]
25+
pub use futures_task::noop_waker_ref;

0 commit comments

Comments
 (0)