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<(), SubmissionError>
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

Ok(()) if the blocking domain accepts the task.

§Errors

Returns SubmissionError if the blocking domain refuses the task.

Source

pub fn submit_tracked_blocking<T, E>( &self, task: T, ) -> Result<TrackedTask<(), E>, SubmissionError>
where T: Runnable<E> + Send + 'static, E: Send + 'static,

Submits a blocking runnable task and returns a tracked handle.

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

A TrackedTask for the accepted blocking task.

§Errors

Returns SubmissionError if the blocking domain refuses the task.

Source

pub fn submit_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TaskHandle<R, E>, SubmissionError>
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 SubmissionError if the blocking domain refuses the task.

Source

pub fn submit_tracked_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TrackedTask<R, E>, SubmissionError>
where C: Callable<R, E> + Send + 'static, R: Send + 'static, E: Send + 'static,

Submits a blocking callable task and returns a tracked handle.

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

A TrackedTask for the accepted blocking task.

§Errors

Returns SubmissionError if the blocking domain refuses the task.

Source

pub fn submit_cpu<T, E>(&self, task: T) -> Result<(), SubmissionError>
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

Ok(()) if the CPU domain accepts the task.

§Errors

Returns SubmissionError if the CPU domain refuses the task.

Source

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

Submits a CPU-bound runnable task and returns a tracked handle.

§Parameters
  • task - Runnable CPU task.
§Returns

A RayonTaskHandle for the accepted CPU task.

§Errors

Returns SubmissionError if the CPU domain refuses the task.

Source

pub fn submit_cpu_callable<C, R, E>( &self, task: C, ) -> Result<TaskHandle<R, E>, SubmissionError>
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 TaskHandle for the accepted CPU task.

§Errors

Returns SubmissionError if the CPU domain refuses the task.

Source

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

Submits a CPU-bound callable task and returns a tracked handle.

§Parameters
  • task - Callable CPU task.
§Returns

A RayonTaskHandle for the accepted CPU task.

§Errors

Returns SubmissionError if the CPU domain refuses the task.

Source

pub fn submit_tokio_blocking<T, E>( &self, task: T, ) -> Result<(), SubmissionError>
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

Ok(()) if the Tokio blocking domain accepts the task.

§Errors

Returns SubmissionError if the Tokio blocking domain refuses the task.

Source

pub fn submit_tracked_tokio_blocking<T, E>( &self, task: T, ) -> Result<TrackedTask<(), E>, SubmissionError>
where T: Runnable<E> + Send + 'static, E: Send + 'static,

Submits a blocking runnable task to Tokio and returns a tracked handle.

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

A TrackedTask for the accepted blocking task.

§Errors

Returns SubmissionError if the Tokio blocking domain refuses the task.

Source

pub fn submit_tokio_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TaskHandle<R, E>, SubmissionError>
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 TaskHandle for the accepted blocking task.

§Errors

Returns SubmissionError if the Tokio blocking domain refuses the task.

Source

pub fn submit_tracked_tokio_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TrackedTask<R, E>, SubmissionError>
where C: Callable<R, E> + Send + 'static, R: Send + 'static, E: Send + 'static,

Submits a blocking callable task to Tokio and returns a tracked handle.

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

A TrackedTask for the accepted blocking task.

§Errors

Returns SubmissionError if the Tokio blocking domain refuses the task.

Source

pub fn spawn_io<F, R, E>( &self, future: F, ) -> Result<TokioTaskHandle<R, E>, SubmissionError>
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 SubmissionError if the Tokio IO domain refuses the task.

Source

pub fn shutdown(&self)

Requests graceful shutdown for every execution domain.

Source

pub fn stop(&self) -> ExecutionServicesStopReport

Requests abrupt stop for every execution domain.

§Returns

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

Source

pub fn lifecycle(&self) -> ExecutorServiceLifecycle

Returns the aggregate lifecycle state.

§Returns

ExecutorServiceLifecycle::Terminated if all domains have terminated; ExecutorServiceLifecycle::Stopping if any domain is stopping; ExecutorServiceLifecycle::ShuttingDown if any domain is no longer running; otherwise ExecutorServiceLifecycle::Running.

Source

pub fn is_running(&self) -> bool

Returns whether every execution domain is running.

§Returns

true only if all execution domains are running.

Source

pub fn is_shutting_down(&self) -> bool

Returns whether any execution domain is gracefully shutting down.

§Returns

true when the aggregate lifecycle is ExecutorServiceLifecycle::ShuttingDown.

Source

pub fn is_stopping(&self) -> bool

Returns whether any execution domain is stopping abruptly.

§Returns

true when the aggregate lifecycle is ExecutorServiceLifecycle::Stopping.

Source

pub fn is_not_running(&self) -> bool

Returns whether the facade is no longer fully running.

§Returns

true after any execution domain starts shutdown, stop, or has already terminated.

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

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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> IntoResult<T> for T

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.