pub struct TokioIoExecutorService { /* private fields */ }Expand description
Tokio-backed executor service for async IO and Future-based tasks.
Accepted futures are spawned with tokio::spawn, so waiting for external
IO does not occupy a dedicated blocking thread.
TokioIoExecutorService intentionally has no service-level
await_termination method. Await the task handles returned by
Self::spawn when the caller needs to observe async task completion.
use qubit_tokio_executor::TokioIoExecutorService;
let service = TokioIoExecutorService::new();
service.await_termination().await;Implementations§
Source§impl TokioIoExecutorService
impl TokioIoExecutorService
Sourcepub fn new() -> TokioIoExecutorService
pub fn new() -> TokioIoExecutorService
Sourcepub fn spawn<F, R, E>(
&self,
future: F,
) -> Result<TokioTaskHandle<R, E>, SubmissionError>
pub fn spawn<F, R, E>( &self, future: F, ) -> Result<TokioTaskHandle<R, E>, SubmissionError>
Accepts an async task and spawns it on the current Tokio runtime.
§Parameters
future- Future to execute on Tokio’s async scheduler.
§Returns
A TokioTaskHandle for the accepted task.
§Errors
Returns SubmissionError::Shutdown if shutdown has already been
requested before the task is accepted. Returns
SubmissionError::WorkerSpawnFailed if the current thread is not
entered into a Tokio runtime.
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Stops accepting new async tasks.
Already accepted tasks are allowed to finish unless aborted through
their handles or by Self::stop.
Sourcepub fn stop(&self) -> StopReport
pub fn stop(&self) -> StopReport
Stops accepting new tasks and aborts tracked async tasks.
§Returns
A report with zero queued tasks, the observed active-task count, and the number of Tokio abort handles signalled.
Sourcepub fn lifecycle(&self) -> ExecutorServiceLifecycle
pub fn lifecycle(&self) -> ExecutorServiceLifecycle
Returns the current lifecycle state.
§Returns
ExecutorServiceLifecycle::Terminated after shutdown or stop and
once no accepted async task remains active.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns whether this service still accepts async tasks.
§Returns
true only while the lifecycle is ExecutorServiceLifecycle::Running.
Sourcepub fn is_shutting_down(&self) -> bool
pub fn is_shutting_down(&self) -> bool
Returns whether graceful shutdown is in progress.
§Returns
true only while the lifecycle is
ExecutorServiceLifecycle::ShuttingDown.
Sourcepub fn is_stopping(&self) -> bool
pub fn is_stopping(&self) -> bool
Returns whether abrupt stop is in progress.
§Returns
true only while the lifecycle is ExecutorServiceLifecycle::Stopping.
Sourcepub fn is_not_running(&self) -> bool
pub fn is_not_running(&self) -> bool
Returns whether shutdown has been requested.
§Returns
true if this service no longer accepts new async tasks.
Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Returns whether shutdown was requested and all async tasks are finished.
§Returns
true only after shutdown has been requested and no accepted async
tasks remain active.
Trait Implementations§
Source§impl Clone for TokioIoExecutorService
impl Clone for TokioIoExecutorService
Source§fn clone(&self) -> TokioIoExecutorService
fn clone(&self) -> TokioIoExecutorService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for TokioIoExecutorService
impl Default for TokioIoExecutorService
Source§fn default() -> TokioIoExecutorService
fn default() -> TokioIoExecutorService
Auto Trait Implementations§
impl Freeze for TokioIoExecutorService
impl RefUnwindSafe for TokioIoExecutorService
impl Send for TokioIoExecutorService
impl Sync for TokioIoExecutorService
impl Unpin for TokioIoExecutorService
impl UnsafeUnpin for TokioIoExecutorService
impl UnwindSafe for TokioIoExecutorService
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