pub struct RayonExecutorService { /* private fields */ }Expand description
Rayon-backed executor service for CPU-bound synchronous tasks.
Accepted tasks are executed on a dedicated Rayon thread pool. The service
preserves the crate’s ExecutorService lifecycle semantics and task-handle
APIs while delegating scheduling to Rayon.
Implementations§
Source§impl RayonExecutorService
impl RayonExecutorService
Sourcepub fn new() -> Result<Self, RayonExecutorServiceBuildError>
pub fn new() -> Result<Self, RayonExecutorServiceBuildError>
Creates a Rayon executor service with default builder settings.
§Returns
Ok(RayonExecutorService) if the default Rayon thread pool can be
built.
§Errors
Returns RayonExecutorServiceBuildError if the default builder
configuration is rejected.
Sourcepub fn builder() -> RayonExecutorServiceBuilder
pub fn builder() -> RayonExecutorServiceBuilder
Creates a builder for configuring a Rayon executor service.
§Returns
A builder configured with CPU-parallelism defaults.
Trait Implementations§
Source§impl Clone for RayonExecutorService
impl Clone for RayonExecutorService
Source§fn clone(&self) -> RayonExecutorService
fn clone(&self) -> RayonExecutorService
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ExecutorService for RayonExecutorService
impl ExecutorService for RayonExecutorService
Source§fn submit_callable<C, R, E>(
&self,
task: C,
) -> Result<Self::Handle<R, E>, RejectedExecution>
fn submit_callable<C, R, E>( &self, task: C, ) -> Result<Self::Handle<R, E>, RejectedExecution>
Accepts a callable and schedules it on the Rayon thread pool.
§Parameters
task- Callable to execute on a Rayon worker.
§Returns
A RayonTaskHandle for the accepted task.
§Errors
Returns RejectedExecution::Shutdown if shutdown has already been
requested before the task is accepted.
Source§fn shutdown(&self)
fn shutdown(&self)
Stops accepting new tasks.
Already accepted Rayon tasks are allowed to finish normally.
Source§fn shutdown_now(&self) -> ShutdownReport
fn shutdown_now(&self) -> ShutdownReport
Stops accepting new tasks and cancels tasks that have not started yet.
Running Rayon tasks cannot be preempted. Cancellation therefore applies only to tasks that are still pending when the cancellation hook wins the race against task start.
§Returns
A count-based report describing the pending and running work observed at the time of the shutdown request, plus the number of pending tasks for which cancellation succeeded.
Source§fn is_shutdown(&self) -> bool
fn is_shutdown(&self) -> bool
Returns whether shutdown has been requested.
Source§fn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
Returns whether shutdown was requested and no accepted tasks remain.
Source§fn await_termination(&self) -> Self::Termination<'_>
fn await_termination(&self) -> Self::Termination<'_>
Waits until the service has terminated.
§Returns
A future that resolves after shutdown has been requested and all accepted Rayon tasks have completed or been cancelled before start.
Source§type Handle<R, E> = RayonTaskHandle<R, E>
where
R: Send + 'static,
E: Send + 'static
type Handle<R, E> = RayonTaskHandle<R, E> where R: Send + 'static, E: Send + 'static
Auto Trait Implementations§
impl Freeze for RayonExecutorService
impl !RefUnwindSafe for RayonExecutorService
impl Send for RayonExecutorService
impl Sync for RayonExecutorService
impl Unpin for RayonExecutorService
impl UnsafeUnpin for RayonExecutorService
impl !UnwindSafe for RayonExecutorService
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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