Executor

Struct Executor 

Source
pub struct Executor { /* private fields */ }
Expand description

Core task execution engine for the Luminal runtime

The Executor is responsible for scheduling and executing tasks. It maintains a global task queue and a set of worker threads that process tasks using a work-stealing algorithm.

Implementations§

Source§

impl Executor

Source

pub fn new() -> Self

Creates a new executor

This initializes a new executor with worker threads based on the number of available CPU cores.

§Returns

A new Executor instance

Source

pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Spawns a future onto the executor

This wraps the future in a task and schedules it for execution, returning a JoinHandle that can be used to await its completion.

§Type Parameters
  • F - The future type
§Parameters
  • future - The future to execute
§Returns

A JoinHandle for the spawned task

Source

pub fn block_on<F>(&self, future: F) -> F::Output
where F: Future + Send + 'static, F::Output: Send + 'static,

Blocks the current thread until the provided future completes

This spawns the future as a task and then actively helps execute tasks from the queue until the specified future completes.

§Type Parameters
  • F - The future type
§Parameters
  • future - The future to execute and wait for
§Returns

The output of the future

§Panics

Panics if the task times out (after 30 seconds) or the task channel is disconnected

Source

pub fn run(&self)

Runs the executor until the task queue is empty

This method is primarily used for testing and benchmarking.

Source

pub fn stats(&self) -> (usize, usize)

Returns statistics about the executor

§Returns

A tuple containing the current queue length and the number of tasks processed

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> 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, 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.