22
33//! Types and Traits for working with asynchronous tasks.
44//!
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
78//! `#[cfg(target_has_atomic = "ptr")]`.
89
910use core:: mem:: ManuallyDrop ;
10- use core:: task:: { LocalWaker , RawWaker , RawWakerVTable , Waker } ;
11-
11+ use core:: task:: { LocalWaker , RawWaker , RawWakerVTable } ;
1212use crate :: rc:: Rc ;
13- use crate :: sync:: Arc ;
13+
14+ #[ cfg( target_has_atomic = "ptr" ) ]
15+ use core:: { task:: Waker , sync:: Arc } ;
1416
1517/// The implementation of waking a task on an executor.
1618///
@@ -74,6 +76,7 @@ use crate::sync::Arc;
7476/// println!("Hi from inside a future!");
7577/// });
7678/// ```
79+ #[ cfg( target_has_atomic = "ptr" ) ]
7780#[ stable( feature = "wake_trait" , since = "1.51.0" ) ]
7881pub trait Wake {
7982 /// Wake this task.
@@ -92,7 +95,7 @@ pub trait Wake {
9295 self . clone ( ) . wake ( ) ;
9396 }
9497}
95-
98+ # [ cfg ( target_has_atomic = "ptr" ) ]
9699#[ stable( feature = "wake_trait" , since = "1.51.0" ) ]
97100impl < W : Wake + Send + Sync + ' static > From < Arc < W > > for Waker {
98101 /// Use a `Wake`-able type as a `Waker`.
@@ -104,7 +107,7 @@ impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for Waker {
104107 unsafe { Waker :: from_raw ( raw_waker ( waker) ) }
105108 }
106109}
107-
110+ # [ cfg ( target_has_atomic = "ptr" ) ]
108111#[ stable( feature = "wake_trait" , since = "1.51.0" ) ]
109112impl < W : Wake + Send + Sync + ' static > From < Arc < W > > for RawWaker {
110113 /// Use a `Wake`-able type as a `RawWaker`.
@@ -120,6 +123,7 @@ impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for RawWaker {
120123// the safety of `From<Arc<W>> for Waker` does not depend on the correct
121124// trait dispatch - instead both impls call this function directly and
122125// explicitly.
126+ #[ cfg( target_has_atomic = "ptr" ) ]
123127#[ inline( always) ]
124128fn raw_waker < W : Wake + Send + Sync + ' static > ( waker : Arc < W > ) -> RawWaker {
125129 // Increment the reference count of the arc to clone it.
0 commit comments