Skip to main content

TokioExecutorService

Struct TokioExecutorService 

Source
pub struct TokioExecutorService { /* private fields */ }
Expand description

Tokio-backed service for submitted blocking tasks.

The service accepts fallible Runnable and Callable tasks, runs them through Tokio, and returns awaitable handles for their final results.

Implementations§

Source§

impl TokioExecutorService

Source

pub fn new() -> Self

Creates a new service instance.

§Returns

A Tokio-backed executor service.

Trait Implementations§

Source§

impl Clone for TokioExecutorService

Source§

fn clone(&self) -> TokioExecutorService

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for TokioExecutorService

Source§

fn default() -> TokioExecutorService

Returns the “default value” for a type. Read more
Source§

impl ExecutorService for TokioExecutorService

Source§

fn submit_callable<C, R, E>( &self, task: C, ) -> Result<Self::Handle<R, E>, RejectedExecution>
where C: Callable<R, E> + Send + 'static, R: Send + 'static, E: Send + 'static,

Accepts a callable and runs it through Tokio.

§Parameters
  • task - Callable to execute on Tokio’s blocking task pool.
§Returns

A TokioTaskHandle for the accepted task.

§Errors

Returns RejectedExecution::Shutdown if shutdown has already been requested before the task is accepted.

Source§

fn shutdown(&self)

Stops accepting new tasks.

Already accepted tasks are allowed to finish unless they are cancelled before their blocking closure starts.

Source§

fn shutdown_now(&self) -> ShutdownReport

Stops accepting new tasks and requests abort for tracked Tokio tasks.

Tokio cannot abort blocking tasks that have already started. Such tasks continue running and keep the service active until their closure returns.

§Returns

A report with zero queued tasks, the observed active task count, and the number of Tokio abort handles signalled.

Source§

fn is_shutdown(&self) -> bool

Returns whether shutdown has been requested.

Source§

fn is_terminated(&self) -> bool

Returns whether shutdown was requested and all tasks are finished.

Source§

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 Tokio blocking tasks have finished or were cancelled before their closures started.

Source§

type Handle<R, E> = TokioTaskHandle<R, E> where R: Send + 'static, E: Send + 'static

Handle returned for an accepted task.
Source§

type Termination<'a> = Pin<Box<dyn Future<Output = ()> + Send + 'a>> where Self: 'a

Future returned when waiting for service termination.
Source§

fn submit<T, E>( &self, task: T, ) -> Result<Self::Handle<(), E>, RejectedExecution>
where T: Runnable<E> + Send + 'static, E: Send + 'static,

Submits a runnable task to this service. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.