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 Tokiospawn_blocking.io: async futures spawned on Tokio’s async runtime.
Implementations§
Source§impl ExecutionServices
impl ExecutionServices
Sourcepub fn new() -> Result<Self, ExecutionServicesBuildError>
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.
Sourcepub fn builder() -> ExecutionServicesBuilder
pub fn builder() -> ExecutionServicesBuilder
Creates a builder for configuring the execution-services facade.
§Returns
A builder configured with CPU-parallelism defaults.
Sourcepub fn blocking(&self) -> &BlockingExecutorService
pub fn blocking(&self) -> &BlockingExecutorService
Returns the blocking execution domain.
§Returns
A shared reference to the blocking executor service.
Sourcepub fn cpu(&self) -> &RayonExecutorService
pub fn cpu(&self) -> &RayonExecutorService
Returns the CPU execution domain.
§Returns
A shared reference to the Rayon-backed CPU executor service.
Sourcepub fn tokio_blocking(&self) -> &TokioBlockingExecutorService
pub fn tokio_blocking(&self) -> &TokioBlockingExecutorService
Returns the Tokio blocking execution domain.
§Returns
A shared reference to the Tokio blocking executor service.
Sourcepub fn io(&self) -> &TokioIoExecutorService
pub fn io(&self) -> &TokioIoExecutorService
Returns the Tokio async IO execution domain.
§Returns
A shared reference to the Tokio IO executor service.
Sourcepub fn submit_blocking<T, E>(&self, task: T) -> Result<(), SubmissionError>
pub fn submit_blocking<T, E>(&self, task: T) -> Result<(), SubmissionError>
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.
Sourcepub fn submit_tracked_blocking<T, E>(
&self,
task: T,
) -> Result<TrackedTask<(), E>, SubmissionError>
pub fn submit_tracked_blocking<T, E>( &self, task: T, ) -> Result<TrackedTask<(), E>, SubmissionError>
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.
Sourcepub fn submit_blocking_callable<C, R, E>(
&self,
task: C,
) -> Result<TaskHandle<R, E>, SubmissionError>
pub fn submit_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TaskHandle<R, E>, SubmissionError>
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.
Sourcepub fn submit_tracked_blocking_callable<C, R, E>(
&self,
task: C,
) -> Result<TrackedTask<R, E>, SubmissionError>
pub fn submit_tracked_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TrackedTask<R, E>, SubmissionError>
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.
Sourcepub fn submit_cpu<T, E>(&self, task: T) -> Result<(), SubmissionError>
pub fn submit_cpu<T, E>(&self, task: T) -> Result<(), SubmissionError>
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.
Sourcepub fn submit_tracked_cpu<T, E>(
&self,
task: T,
) -> Result<RayonTaskHandle<(), E>, SubmissionError>
pub fn submit_tracked_cpu<T, E>( &self, task: T, ) -> Result<RayonTaskHandle<(), E>, SubmissionError>
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.
Sourcepub fn submit_cpu_callable<C, R, E>(
&self,
task: C,
) -> Result<TaskHandle<R, E>, SubmissionError>
pub fn submit_cpu_callable<C, R, E>( &self, task: C, ) -> Result<TaskHandle<R, E>, SubmissionError>
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.
Sourcepub fn submit_tracked_cpu_callable<C, R, E>(
&self,
task: C,
) -> Result<RayonTaskHandle<R, E>, SubmissionError>
pub fn submit_tracked_cpu_callable<C, R, E>( &self, task: C, ) -> Result<RayonTaskHandle<R, E>, SubmissionError>
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.
Sourcepub fn submit_tokio_blocking<T, E>(
&self,
task: T,
) -> Result<(), SubmissionError>
pub fn submit_tokio_blocking<T, E>( &self, task: T, ) -> Result<(), SubmissionError>
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.
Sourcepub fn submit_tracked_tokio_blocking<T, E>(
&self,
task: T,
) -> Result<TrackedTask<(), E>, SubmissionError>
pub fn submit_tracked_tokio_blocking<T, E>( &self, task: T, ) -> Result<TrackedTask<(), E>, SubmissionError>
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.
Sourcepub fn submit_tokio_blocking_callable<C, R, E>(
&self,
task: C,
) -> Result<TaskHandle<R, E>, SubmissionError>
pub fn submit_tokio_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TaskHandle<R, E>, SubmissionError>
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.
Sourcepub fn submit_tracked_tokio_blocking_callable<C, R, E>(
&self,
task: C,
) -> Result<TrackedTask<R, E>, SubmissionError>
pub fn submit_tracked_tokio_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TrackedTask<R, E>, SubmissionError>
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.
Sourcepub fn spawn_io<F, R, E>(
&self,
future: F,
) -> Result<TokioTaskHandle<R, E>, SubmissionError>
pub fn spawn_io<F, R, E>( &self, future: F, ) -> Result<TokioTaskHandle<R, E>, SubmissionError>
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.
Sourcepub fn stop(&self) -> ExecutionServicesStopReport
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.
Sourcepub fn lifecycle(&self) -> ExecutorServiceLifecycle
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.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns whether every execution domain is running.
§Returns
true only if all execution domains are running.
Sourcepub fn is_shutting_down(&self) -> bool
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.
Sourcepub fn is_stopping(&self) -> bool
pub fn is_stopping(&self) -> bool
Returns whether any execution domain is stopping abruptly.
§Returns
true when the aggregate lifecycle is
ExecutorServiceLifecycle::Stopping.
Sourcepub fn is_not_running(&self) -> bool
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.
Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Returns whether every execution domain has terminated.
§Returns
true only after all execution domains have terminated.
Auto Trait Implementations§
impl Freeze for ExecutionServices
impl !RefUnwindSafe for ExecutionServices
impl Send for ExecutionServices
impl Sync for ExecutionServices
impl Unpin for ExecutionServices
impl UnsafeUnpin for ExecutionServices
impl !UnwindSafe for ExecutionServices
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
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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