2
2
3
3
//! Types and Traits for working with asynchronous tasks.
4
4
//!
5
- //! **Note**: This module is only available on platforms that support atomic
6
- //! loads and stores of pointers. This may be detected at compile time using
5
+ //! **Note**: Some of the types in this module are only available
6
+ //! on platforms that support atomic loads and stores of pointers.
7
+ //! This may be detected at compile time using
7
8
//! `#[cfg(target_has_atomic = "ptr")]`.
8
9
9
10
use core:: mem:: ManuallyDrop ;
10
- use core:: task:: { LocalWaker , RawWaker , RawWakerVTable , Waker } ;
11
-
11
+ use core:: task:: { LocalWaker , RawWaker , RawWakerVTable } ;
12
12
use crate :: rc:: Rc ;
13
- use crate :: sync:: Arc ;
13
+
14
+ #[ cfg( target_has_atomic = "ptr" ) ]
15
+ use core:: { task:: Waker , sync:: Arc } ;
14
16
15
17
/// The implementation of waking a task on an executor.
16
18
///
@@ -74,6 +76,7 @@ use crate::sync::Arc;
74
76
/// println!("Hi from inside a future!");
75
77
/// });
76
78
/// ```
79
+ #[ cfg( target_has_atomic = "ptr" ) ]
77
80
#[ stable( feature = "wake_trait" , since = "1.51.0" ) ]
78
81
pub trait Wake {
79
82
/// Wake this task.
@@ -92,7 +95,7 @@ pub trait Wake {
92
95
self . clone ( ) . wake ( ) ;
93
96
}
94
97
}
95
-
98
+ # [ cfg ( target_has_atomic = "ptr" ) ]
96
99
#[ stable( feature = "wake_trait" , since = "1.51.0" ) ]
97
100
impl < W : Wake + Send + Sync + ' static > From < Arc < W > > for Waker {
98
101
/// Use a `Wake`-able type as a `Waker`.
@@ -104,7 +107,7 @@ impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for Waker {
104
107
unsafe { Waker :: from_raw ( raw_waker ( waker) ) }
105
108
}
106
109
}
107
-
110
+ # [ cfg ( target_has_atomic = "ptr" ) ]
108
111
#[ stable( feature = "wake_trait" , since = "1.51.0" ) ]
109
112
impl < W : Wake + Send + Sync + ' static > From < Arc < W > > for RawWaker {
110
113
/// Use a `Wake`-able type as a `RawWaker`.
@@ -120,6 +123,7 @@ impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for RawWaker {
120
123
// the safety of `From<Arc<W>> for Waker` does not depend on the correct
121
124
// trait dispatch - instead both impls call this function directly and
122
125
// explicitly.
126
+ #[ cfg( target_has_atomic = "ptr" ) ]
123
127
#[ inline( always) ]
124
128
fn raw_waker < W : Wake + Send + Sync + ' static > ( waker : Arc < W > ) -> RawWaker {
125
129
// Increment the reference count of the arc to clone it.
0 commit comments