zephyr::work::futures

Struct WakeInfo

Source
pub struct WakeInfo {
    pub events: ArrayVec<UnsafeCell<k_poll_event>, 1>,
    pub timeout: Timeout,
    pub context: Context<'static>,
    /* private fields */
}
Expand description

Futures will need to be able to set the events and timeout of this waker. Because the Waker is parameterized, they will not have access to the whole WorkWaker, but only this WakeInfo.

Fields§

§events: ArrayVec<UnsafeCell<k_poll_event>, 1>

Events to use for our next wakeup. Currently cleared before calling the future (although this discards the wakeup reason, so needs to be fixed).

§timeout: Timeout

Timeout to use for the next wakeup. Will be set to Forever before calling the Future’s poll.

§context: Context<'static>

A Context to use for invoking workers. This WakeInfo can be recovered from this context. Note that our contexts are 'static as they are maintained inside of the worker.

Implementations§

Source§

impl WakeInfo

Source

pub unsafe fn from_context<'b>(context: &'b mut Context<'_>) -> &'b mut Self

Recover the WakeInfo from a given context.

§Safety

Although the lifetime of Context is 'static, the generic type passed to Future does not specify a lifetime. As such, it is not possible for the future to store the Context, and rescheduling must be specified before this Future invocation returns.

This does assume we are only using the Zephyr scheduler. The Context does have an any-based data pointer mechanism, but it is nightly. This recovery would be easier using that mechanism.

Source

pub fn add_semaphore<'a>(&'a mut self, sem: &'a Semaphore)

Add an event that represents waiting for a semaphore to be available for “take”.

Source

pub fn add_signal<'a>(&'a mut self, signal: &'a Signal)

Add an event that represents waiting for a signal.

Source

pub fn add_queue<'a>(&'a mut self, queue: &'a Queue)

Add an event that represents waiting for a queue to have a message.

Auto Trait Implementations§

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.