pub struct RawWaker { /* private fields */ }
Expand description
A RawWaker
allows the implementor of a task executor to create a Waker
or a LocalWaker
which provides customized wakeup behavior.
It consists of a data pointer and a virtual function pointer table (vtable)
that customizes the behavior of the RawWaker
.
RawWaker
s are unsafe to use.
Implementing the Wake
trait is a safe alternative that requires memory allocation.
Implementations§
Source§impl RawWaker
impl RawWaker
1.36.0 (const: 1.36.0) · Sourcepub const fn new(data: *const (), vtable: &'static RawWakerVTable) -> RawWaker
pub const fn new(data: *const (), vtable: &'static RawWakerVTable) -> RawWaker
Creates a new RawWaker
from the provided data
pointer and vtable
.
The data
pointer can be used to store arbitrary data as required
by the executor. This could be e.g. a type-erased pointer to an Arc
that is associated with the task.
The value of this pointer will get passed to all functions that are part
of the vtable
as the first parameter.
It is important to consider that the data
pointer must point to a
thread safe type such as an [Arc]<T: Send + Sync>
when used to construct a Waker
. This restriction is lifted when
constructing a LocalWaker
, which allows using types that do not implement
Send + Sync
like [Rc]<T>
.
The vtable
customizes the behavior of a Waker
which gets created
from a RawWaker
. For each operation on the Waker
, the associated
function in the vtable
of the underlying RawWaker
will be called.
Trait Implementations§
impl StructuralPartialEq for RawWaker
Auto Trait Implementations§
impl Freeze for RawWaker
impl RefUnwindSafe for RawWaker
impl !Send for RawWaker
impl !Sync for RawWaker
impl Unpin for RawWaker
impl UnwindSafe for RawWaker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes