Struct RawWaker

pub struct RawWaker { pub(in ::task::wake) data: *const (), pub(in ::task::wake) vtable: &'static RawWakerVTable }

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.

RawWakers are unsafe to use. Implementing the Wake trait is a safe alternative that requires memory allocation.

Fields

data: *const ()

A data pointer, which 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 field gets passed to all functions that are part of the vtable as the first parameter.

vtable: &'static RawWakerVTable

Virtual function pointer table that customizes the behavior of this waker.

Implementations

impl RawWaker

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.

const NOOP: RawWaker = _;

Trait Implementations

impl Debug for RawWaker

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl PartialEq for RawWaker

fn eq(&self, other: &RawWaker) -> bool

impl StructuralPartialEq for RawWaker

Auto Trait Implementations

impl !Send for RawWaker

impl !Sync for RawWaker

impl Freeze for RawWaker

impl RefUnwindSafe for RawWaker

impl Unpin for RawWaker

impl UnsafeUnpin for RawWaker

impl UnwindSafe for RawWaker

Blanket Implementations

impl<T> Any for RawWaker where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for RawWaker where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for RawWaker where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for RawWaker

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for RawWaker where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for RawWaker

impl<T, U> Into<U> for RawWaker where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for RawWaker where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for RawWaker where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>