Header

Struct Header 

Source
pub(crate) struct Header<M> {
    pub(crate) state: AtomicUsize,
    pub(crate) awaiter: UnsafeCell<Option<Waker>>,
    pub(crate) vtable: &'static TaskVTable,
    pub(crate) metadata: M,
    pub(crate) propagate_panic: bool,
}
Expand description

The header of a task.

This header is stored in memory at the beginning of the heap-allocated task.

Fields§

§state: AtomicUsize

Current state of the task.

Contains flags representing the current state and the reference count.

§awaiter: UnsafeCell<Option<Waker>>

The task that is blocked on the Task handle.

This waker needs to be woken up once the task completes or is closed.

§vtable: &'static TaskVTable

The virtual table.

In addition to the actual waker virtual table, it also contains pointers to several other methods necessary for bookkeeping the heap-allocated task.

§metadata: M

Metadata associated with the task.

This metadata may be provided to the user.

§propagate_panic: bool

Whether or not a panic that occurs in the task should be propagated.

Implementations§

Source§

impl<M> Header<M>

Source

pub(crate) fn notify(&self, current: Option<&Waker>)

Notifies the awaiter blocked on this task.

If the awaiter is the same as the current waker, it will not be notified.

Source

pub(crate) fn take(&self, current: Option<&Waker>) -> Option<Waker>

Takes the awaiter blocked on this task.

If there is no awaiter or if it is the same as the current waker, returns None.

Source

pub(crate) fn register(&self, waker: &Waker)

Registers a new awaiter blocked on this task.

This method is called when Task is polled and it has not yet completed.

Trait Implementations§

Source§

impl<M: Debug> Debug for Header<M>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M> !Freeze for Header<M>

§

impl<M> !RefUnwindSafe for Header<M>

§

impl<M> Send for Header<M>
where M: Send,

§

impl<M> !Sync for Header<M>

§

impl<M> Unpin for Header<M>
where M: Unpin,

§

impl<M> UnwindSafe for Header<M>
where M: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.