Skip to main content

TaskCell

Struct TaskCell 

Source
pub struct TaskCell<const SIZE: usize> { /* private fields */ }
Expand description

Generic, zero-allocation storage for one task’s Future state machine.

SIZE is a byte count, chosen by #[rivet::task(stack = SIZE)] (default DEFAULT_TASK_SIZE). The concrete future type is supplied only when polling, via a monomorphized generic method — this is what lets the byte size (and therefore the static declaration) be nameable without knowing the future’s real type.

Implementations§

Source§

impl<const SIZE: usize> TaskCell<SIZE>

Source

pub const fn new() -> Self

Create empty task storage.

Source

pub fn is_completed(&self) -> bool

Whether this task’s future has completed (and been dropped). The executor uses this to skip completed tasks and track the live-task count (plan.md [B10]).

Source

pub unsafe fn poll<F: Future<Output = ()> + 'static>( &self, init: fn() -> F, waker: &Waker, ) -> Poll<()>

Poll the task’s future, creating it on first call via init.

init is the task’s async fn, used as a zero-sized fn() -> F (so tasks currently take no arguments — shared state goes through statics, which is also the idiomatic embedded pattern for peripherals and shared queues).

§Panics

Panics if F doesn’t fit in SIZE bytes or needs stricter alignment than TASK_CELL_ALIGN. Increase #[rivet::task(stack = N)] if this fires.

§Safety

Must only ever be called with the same F on every invocation for a given TaskCell (true by construction: the proc macro generates one non-generic wrapper per task that always calls this with the same init function).

Trait Implementations§

Source§

impl<const SIZE: usize> Default for TaskCell<SIZE>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const SIZE: usize> Sync for TaskCell<SIZE>

Auto Trait Implementations§

§

impl<const SIZE: usize> !Freeze for TaskCell<SIZE>

§

impl<const SIZE: usize> !RefUnwindSafe for TaskCell<SIZE>

§

impl<const SIZE: usize> Send for TaskCell<SIZE>

§

impl<const SIZE: usize> Unpin for TaskCell<SIZE>

§

impl<const SIZE: usize> UnsafeUnpin for TaskCell<SIZE>

§

impl<const SIZE: usize> UnwindSafe for TaskCell<SIZE>

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.