@@ -19,9 +19,29 @@ pub struct RawWaker {
1919 /// that is associated with the task.
2020 /// The value of this field gets passed to all functions that are part of
2121 /// the vtable as the first parameter.
22- pub data : * const ( ) ,
22+ data : * const ( ) ,
2323 /// 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+ }
2545}
2646
2747/// A virtual function pointer table (vtable) that specifies the behavior
@@ -102,8 +122,8 @@ impl Waker {
102122 /// Creates a new `Waker` from [`RawWaker`].
103123 ///
104124 /// 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.
107127 pub unsafe fn new_unchecked ( waker : RawWaker ) -> Waker {
108128 Waker {
109129 waker,
0 commit comments