Executor

Struct Executor 

Source
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: u64

The hardware clock frequency, used to normalize task intervals.

Implementations§

Source§

impl<'curr, 'next> Executor<'curr, 'next>

Source

pub fn new() -> Self

Initializes a new executor and calculates the hardware frequency.

Source

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.

Source

pub fn run_forever(&mut self)

Enters an infinite loop, continuously ticking the executor.

Source

pub fn init_step() -> Context<'curr>

Initializes a no-op Context required for polling futures.

Source

pub fn run_step(&mut self, time: u64, cx: &mut Context<'_>)

Performs a single pass over all registered tasks.

For each node:

  1. Checks if the current time has reached next_run_time.
  2. Polls the future.
  3. If Ready, the node is removed from the list.
  4. If Pending, the next_run_time is 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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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.