@@ -19,9 +19,29 @@ pub struct RawWaker {
19
19
/// that is associated with the task.
20
20
/// The value of this field gets passed to all functions that are part of
21
21
/// the vtable as the first parameter.
22
- pub data : * const ( ) ,
22
+ data : * const ( ) ,
23
23
/// Virtual function pointer table that customizes the behavior of this waker.
24
- pub vtable : & ' static RawWakerVTable ,
24
+ vtable : & ' static RawWakerVTable ,
25
+ }
26
+
27
+ impl RawWaker {
28
+ /// Creates a new `RawWaker` from the provided `data` pointer and `vtable`.
29
+ ///
30
+ /// The `data` pointer can be used to store arbitrary data as required
31
+ /// by the executor. This could be e.g. a type-erased pointer to an `Arc`
32
+ /// that is associated with the task.
33
+ /// The value of this poiner will get passed to all functions that are part
34
+ /// of the `vtable` as the first parameter.
35
+ ///
36
+ /// The `vtable` customizes the behavior of a `Waker` which gets created
37
+ /// from a `RawWaker`. For each operation on the `Waker`, the associated
38
+ /// function in the `vtable` of the underlying `RawWaker` will be called.
39
+ pub const fn new ( data : * const ( ) , vtable : & ' static RawWakerVTable ) -> RawWaker {
40
+ RawWaker {
41
+ data,
42
+ vtable,
43
+ }
44
+ }
25
45
}
26
46
27
47
/// A virtual function pointer table (vtable) that specifies the behavior
@@ -102,8 +122,8 @@ impl Waker {
102
122
/// Creates a new `Waker` from [`RawWaker`].
103
123
///
104
124
/// The behavior of the returned `Waker` is undefined if the contract defined
105
- /// in [RawWaker]'s documentation is not upheld. Therefore this method is
106
- /// unsafe.
125
+ /// in [` RawWaker` ]'s and [`RawWakerVTable`]'s documentation is not upheld.
126
+ /// Therefore this method is unsafe.
107
127
pub unsafe fn new_unchecked ( waker : RawWaker ) -> Waker {
108
128
Waker {
109
129
waker,
0 commit comments