@@ -3,20 +3,31 @@ use alloc::sync::Arc;
3
3
/// A way of waking up a specific task.
4
4
///
5
5
/// By implementing this trait, types that are expected to be wrapped in an `Arc`
6
- /// can be converted into `Waker` objects.
6
+ /// can be converted into [ `Waker`] objects.
7
7
/// Those Wakers can be used to signal executors that a task it owns
8
8
/// is ready to be `poll`ed again.
9
+ ///
10
+ /// Currently, there are two ways to convert `ArcWake` into [`Waker`]:
11
+ ///
12
+ /// * [`waker`](crate::task::waker()) converts `Arc<impl ArcWake>` into [`Waker`].
13
+ /// * [`waker_ref`](crate::task::waker_ref()) converts `&Arc<impl ArcWake>` into [`WakerRef`] that
14
+ /// provides access to a [`&Waker`][`Waker`].
15
+ ///
16
+ /// [`Waker`]: std::task::Waker
17
+ /// [`WakerRef`]: crate::task::WakerRef
9
18
// Note: Send + Sync required because `Arc<T>` doesn't automatically imply
10
19
// those bounds, but `Waker` implements them.
11
20
pub trait ArcWake : Send + Sync {
12
21
/// Indicates that the associated task is ready to make progress and should
13
22
/// be `poll`ed.
14
23
///
15
24
/// This function can be called from an arbitrary thread, including threads which
16
- /// did not create the `ArcWake` based `Waker`.
25
+ /// did not create the `ArcWake` based [ `Waker`] .
17
26
///
18
27
/// Executors generally maintain a queue of "ready" tasks; `wake` should place
19
28
/// the associated task onto this queue.
29
+ ///
30
+ /// [`Waker`]: std::task::Waker
20
31
fn wake ( self : Arc < Self > ) {
21
32
Self :: wake_by_ref ( & self )
22
33
}
@@ -25,12 +36,14 @@ pub trait ArcWake: Send + Sync {
25
36
/// be `poll`ed.
26
37
///
27
38
/// This function can be called from an arbitrary thread, including threads which
28
- /// did not create the `ArcWake` based `Waker`.
39
+ /// did not create the `ArcWake` based [ `Waker`] .
29
40
///
30
41
/// Executors generally maintain a queue of "ready" tasks; `wake_by_ref` should place
31
42
/// the associated task onto this queue.
32
43
///
33
- /// This function is similar to `wake`, but must not consume the provided data
44
+ /// This function is similar to [ `wake`](ArcWake::wake) , but must not consume the provided data
34
45
/// pointer.
46
+ ///
47
+ /// [`Waker`]: std::task::Waker
35
48
fn wake_by_ref ( arc_self : & Arc < Self > ) ;
36
49
}
0 commit comments