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>
impl<const SIZE: usize> TaskCell<SIZE>
Sourcepub fn is_completed(&self) -> bool
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]).
Sourcepub unsafe fn poll<F: Future<Output = ()> + 'static>(
&self,
init: fn() -> F,
waker: &Waker,
) -> Poll<()>
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).