pub struct ThreadPerTaskExecutorService { /* private fields */ }Expand description
Managed service that runs every accepted task on a dedicated OS thread.
The service has no queue: accepted tasks start immediately on their own thread. Shutdown prevents later submissions but cannot forcefully stop running OS threads.
Implementations§
Trait Implementations§
Source§impl Clone for ThreadPerTaskExecutorService
impl Clone for ThreadPerTaskExecutorService
Source§fn clone(&self) -> ThreadPerTaskExecutorService
fn clone(&self) -> ThreadPerTaskExecutorService
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for ThreadPerTaskExecutorService
impl Default for ThreadPerTaskExecutorService
Source§fn default() -> ThreadPerTaskExecutorService
fn default() -> ThreadPerTaskExecutorService
Source§impl ExecutorService for ThreadPerTaskExecutorService
impl ExecutorService for ThreadPerTaskExecutorService
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 starts it on a dedicated OS thread.
§Parameters
task- Callable to execute on a new OS thread.
§Returns
A TaskHandle for the accepted task.
§Errors
Returns RejectedExecution::Shutdown if shutdown has already been
requested before the task is accepted.
Source§fn shutdown_now(&self) -> ShutdownReport
fn shutdown_now(&self) -> ShutdownReport
Stops accepting new tasks and reports currently running work.
Running OS threads cannot be forcefully stopped by this service.
§Returns
A report with zero queued tasks, the observed active thread count, and zero cancelled tasks.
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 all tasks are finished.
Source§fn await_termination(&self) -> Self::Termination<'_>
fn await_termination(&self) -> Self::Termination<'_>
Waits for all accepted tasks to complete after shutdown.
This future blocks the polling thread while waiting on a condition variable.
§Returns
A future that resolves after shutdown has been requested and all accepted OS-thread tasks have completed.