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<TaskHandle<(), E>, RejectedExecution>
pub fn submit_blocking<T, E>( &self, task: T, ) -> Result<TaskHandle<(), E>, RejectedExecution>
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.
Sourcepub fn submit_blocking_callable<C, R, E>(
&self,
task: C,
) -> Result<TaskHandle<R, E>, RejectedExecution>
pub fn submit_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TaskHandle<R, E>, RejectedExecution>
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.
Sourcepub fn submit_cpu<T, E>(
&self,
task: T,
) -> Result<RayonTaskHandle<(), E>, RejectedExecution>
pub fn submit_cpu<T, E>( &self, task: T, ) -> Result<RayonTaskHandle<(), E>, RejectedExecution>
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.
Sourcepub fn submit_cpu_callable<C, R, E>(
&self,
task: C,
) -> Result<RayonTaskHandle<R, E>, RejectedExecution>
pub fn submit_cpu_callable<C, R, E>( &self, task: C, ) -> Result<RayonTaskHandle<R, E>, RejectedExecution>
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.
Sourcepub fn submit_tokio_blocking<T, E>(
&self,
task: T,
) -> Result<TokioTaskHandle<(), E>, RejectedExecution>
pub fn submit_tokio_blocking<T, E>( &self, task: T, ) -> Result<TokioTaskHandle<(), E>, RejectedExecution>
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.
Sourcepub fn submit_tokio_blocking_callable<C, R, E>(
&self,
task: C,
) -> Result<TokioTaskHandle<R, E>, RejectedExecution>
pub fn submit_tokio_blocking_callable<C, R, E>( &self, task: C, ) -> Result<TokioTaskHandle<R, E>, RejectedExecution>
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.
Sourcepub fn spawn_io<F, R, E>(
&self,
future: F,
) -> Result<TokioTaskHandle<R, E>, RejectedExecution>
pub fn spawn_io<F, R, E>( &self, future: F, ) -> Result<TokioTaskHandle<R, E>, RejectedExecution>
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.
Sourcepub fn shutdown_now(&self) -> ExecutionServicesShutdownReport
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.
Sourcepub fn is_shutdown(&self) -> bool
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.
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> 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