Skip to main content

ExecutionServices

Struct ExecutionServices 

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

Unified facade exposing separate execution domains through one owner.

The facade does not implement a single scheduling core. Instead it routes work to one of four dedicated execution domains:

  • blocking: synchronous tasks that may block an OS thread.
  • cpu: CPU-bound synchronous tasks backed by Rayon.
  • tokio_blocking: blocking tasks routed through Tokio spawn_blocking.
  • io: async futures spawned on Tokio’s async runtime.

Implementations§

Source§

impl ExecutionServices

Source

pub fn new() -> Result<Self, ExecutionServicesBuildError>

Creates an execution-services facade with default builder settings.

§Returns

Ok(ExecutionServices) if the default blocking and CPU domains build successfully.

§Errors

Returns ExecutionServicesBuildError if the default builder configuration is rejected.

Source

pub fn builder() -> ExecutionServicesBuilder

Creates a builder for configuring the execution-services facade.

§Returns

A builder configured with CPU-parallelism defaults.

Source

pub fn blocking(&self) -> &BlockingExecutorService

Returns the blocking execution domain.

§Returns

A shared reference to the blocking executor service.

Source

pub fn cpu(&self) -> &RayonExecutorService

Returns the CPU execution domain.

§Returns

A shared reference to the Rayon-backed CPU executor service.

Source

pub fn tokio_blocking(&self) -> &TokioBlockingExecutorService

Returns the Tokio blocking execution domain.

§Returns

A shared reference to the Tokio blocking executor service.

Source

pub fn io(&self) -> &TokioIoExecutorService

Returns the Tokio async IO execution domain.

§Returns

A shared reference to the Tokio IO executor service.

Source

pub fn submit_blocking<T, E>( &self, task: T, ) -> Result<TaskHandle<(), E>, RejectedExecution>
where T: Runnable<E> + Send + 'static, E: Send + 'static,

Submits a blocking runnable task to the blocking domain.

§Parameters
  • task - Runnable task that may block an OS thread.
§Returns

A TaskHandle for the accepted blocking task.

§Errors

Returns RejectedExecution if the blocking domain refuses the task.

Source

pub fn submit_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TaskHandle<R, E>, RejectedExecution>
where C: Callable<R, E> + Send + 'static, R: Send + 'static, E: Send + 'static,

Submits a blocking callable task to the blocking domain.

§Parameters
  • task - Callable task that may block an OS thread.
§Returns

A TaskHandle for the accepted blocking task.

§Errors

Returns RejectedExecution if the blocking domain refuses the task.

Source

pub fn submit_cpu<T, E>( &self, task: T, ) -> Result<RayonTaskHandle<(), E>, RejectedExecution>
where T: Runnable<E> + Send + 'static, E: Send + 'static,

Submits a CPU-bound runnable task to the Rayon domain.

§Parameters
  • task - Runnable CPU task.
§Returns

A RayonTaskHandle for the accepted CPU task.

§Errors

Returns RejectedExecution if the CPU domain refuses the task.

Source

pub fn submit_cpu_callable<C, R, E>( &self, task: C, ) -> Result<RayonTaskHandle<R, E>, RejectedExecution>
where C: Callable<R, E> + Send + 'static, R: Send + 'static, E: Send + 'static,

Submits a CPU-bound callable task to the Rayon domain.

§Parameters
  • task - Callable CPU task.
§Returns

A RayonTaskHandle for the accepted CPU task.

§Errors

Returns RejectedExecution if the CPU domain refuses the task.

Source

pub fn submit_tokio_blocking<T, E>( &self, task: T, ) -> Result<TokioTaskHandle<(), E>, RejectedExecution>
where T: Runnable<E> + Send + 'static, E: Send + 'static,

Submits a blocking runnable task to Tokio spawn_blocking.

§Parameters
  • task - Runnable task to execute on Tokio’s blocking pool.
§Returns

A TokioTaskHandle for the accepted blocking task.

§Errors

Returns RejectedExecution if the Tokio blocking domain refuses the task.

Source

pub fn submit_tokio_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TokioTaskHandle<R, E>, RejectedExecution>
where C: Callable<R, E> + Send + 'static, R: Send + 'static, E: Send + 'static,

Submits a blocking callable task to Tokio spawn_blocking.

§Parameters
  • task - Callable task to execute on Tokio’s blocking pool.
§Returns

A TokioTaskHandle for the accepted blocking task.

§Errors

Returns RejectedExecution if the Tokio blocking domain refuses the task.

Source

pub fn spawn_io<F, R, E>( &self, future: F, ) -> Result<TokioTaskHandle<R, E>, RejectedExecution>
where F: Future<Output = Result<R, E>> + Send + 'static, R: Send + 'static, E: Send + 'static,

Spawns an async IO or Future-based task on Tokio’s async runtime.

§Parameters
  • future - Future to execute on Tokio’s async scheduler.
§Returns

A TokioTaskHandle for the accepted async task.

§Errors

Returns RejectedExecution if the Tokio IO domain refuses the task.

Source

pub fn shutdown(&self)

Requests graceful shutdown for every execution domain.

Source

pub fn shutdown_now(&self) -> ExecutionServicesShutdownReport

Requests immediate shutdown for every execution domain.

§Returns

A per-domain aggregate report describing queued, running, and cancelled work observed during shutdown.

Source

pub fn is_shutdown(&self) -> bool

Returns whether every execution domain has been shut down.

§Returns

true only if all execution domains no longer accept new tasks.

Source

pub fn is_terminated(&self) -> bool

Returns whether every execution domain has terminated.

§Returns

true only after all execution domains have terminated.

Source

pub fn await_termination(&self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

Waits until every execution domain has terminated.

§Returns

A future that resolves after all execution domains have terminated.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.