pub struct Executor<'curr, 'next> {
pub freq: u64,
/* private fields */
}Available on crate feature
nano-alloc only.Expand description
A simple round-robin executor that manages a linked-list of tasks.
The executor polls tasks based on their scheduled next_run_time
and supports dynamic task addition.
Fields§
§freq: u64The hardware clock frequency, used to normalize task intervals.
Implementations§
Source§impl<'curr, 'next> Executor<'curr, 'next>
impl<'curr, 'next> Executor<'curr, 'next>
Sourcepub fn add(&mut self, node: &'next mut TaskNode<'curr, 'next>) -> &mut Self
pub fn add(&mut self, node: &'next mut TaskNode<'curr, 'next>) -> &mut Self
Adds a task node to the executor.
This method converts the node’s frequency into a tick interval and pushes the node to the front of the linked-list.
Sourcepub fn run_forever(&mut self)
pub fn run_forever(&mut self)
Enters an infinite loop, continuously ticking the executor.
Sourcepub fn run_step(&mut self, time: u64, cx: &mut Context<'_>)
pub fn run_step(&mut self, time: u64, cx: &mut Context<'_>)
Performs a single pass over all registered tasks.
For each node:
- Checks if the current
timehas reachednext_run_time. - Polls the future.
- If
Ready, the node is removed from the list. - If
Pending, thenext_run_timeis updated by the node’s interval.
Auto Trait Implementations§
impl<'curr, 'next> Freeze for Executor<'curr, 'next>
impl<'curr, 'next> !RefUnwindSafe for Executor<'curr, 'next>
impl<'curr, 'next> !Send for Executor<'curr, 'next>
impl<'curr, 'next> !Sync for Executor<'curr, 'next>
impl<'curr, 'next> Unpin for Executor<'curr, 'next>
impl<'curr, 'next> !UnwindSafe for Executor<'curr, 'next>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more