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 (const: unstable) · 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<T, E>(&self, task: T) -> Result<(), SubmissionError>
fn submit<T, E>(&self, task: T) -> Result<(), SubmissionError>
Accepts a runnable and schedules it on the Rayon thread pool.
Source§fn submit_callable<C, R, E>(
&self,
task: C,
) -> Result<Self::ResultHandle<R, E>, SubmissionError>
fn submit_callable<C, R, E>( &self, task: C, ) -> Result<Self::ResultHandle<R, E>, SubmissionError>
Accepts a callable and schedules it on the Rayon thread pool.
§Parameters
task- Callable to execute on a Rayon worker.
§Returns
A TaskHandle for the accepted task.
§Errors
Returns SubmissionError::Shutdown if shutdown has already been
requested before the task is accepted.
Source§fn submit_tracked_callable<C, R, E>(
&self,
task: C,
) -> Result<Self::TrackedHandle<R, E>, SubmissionError>
fn submit_tracked_callable<C, R, E>( &self, task: C, ) -> Result<Self::TrackedHandle<R, E>, SubmissionError>
Accepts a callable and schedules it with a tracked handle.
Source§fn shutdown(&self)
fn shutdown(&self)
Stops accepting new tasks.
Already accepted Rayon tasks are allowed to finish normally.
Source§fn stop(&self) -> StopReport
fn stop(&self) -> StopReport
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 stop request, plus the number of pending tasks for which cancellation succeeded.
Source§fn lifecycle(&self) -> ExecutorServiceLifecycle
fn lifecycle(&self) -> ExecutorServiceLifecycle
Returns the current lifecycle state.
Source§fn is_not_running(&self) -> bool
fn is_not_running(&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 wait_termination(&self)
fn wait_termination(&self)
Blocks until the service has terminated.
Source§type ResultHandle<R, E> = TaskHandle<R, E>
where
R: Send + 'static,
E: Send + 'static
type ResultHandle<R, E> = TaskHandle<R, E> where R: Send + 'static, E: Send + 'static
Source§type TrackedHandle<R, E> = RayonTaskHandle<R, E>
where
R: Send + 'static,
E: Send + 'static
type TrackedHandle<R, E> = RayonTaskHandle<R, E> where R: Send + 'static, E: Send + 'static
Source§fn submit_tracked<T, E>(
&self,
task: T,
) -> Result<Self::TrackedHandle<(), E>, SubmissionError>
fn submit_tracked<T, E>( &self, task: T, ) -> Result<Self::TrackedHandle<(), E>, SubmissionError>
Source§fn is_running(&self) -> bool
fn is_running(&self) -> bool
Source§fn is_shutting_down(&self) -> bool
fn is_shutting_down(&self) -> bool
Source§fn is_stopping(&self) -> bool
fn is_stopping(&self) -> bool
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> 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