Struct SingleThreadExecutor

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

An executor implementation backed by a single thread.

Unfortunately, in order to maintain a 100% “safe” codebase, it can only accept futures with a lifetime of ['static]. The CurrentThreadExecutor does not have this limitation.

This actually uses a CurrentThreadExecutor wrapped in a single thread.

This executor will run all tasks to completion, even when dropped.

Implementations§

Source§

impl SingleThreadExecutor

Source

pub fn new() -> SingleThreadExecutor

Creates a new SingleThreadExecutor and spawns a new thread to back it. The thread immediately starts attempting to execute jobs.

The queue is an unlimited queue, and will happily accept as many jobs as you can pass to it.

Source

pub fn submit<T: Send + 'static, F: Future<Output = T> + Send + 'static>( &mut self, fut: F, ) -> Result<TaskHandle<T>, TaskError>

Submits a new task to be run on this executor. The task will start to be run as soon as the executor has available capacity to run it.

This function returns a TaskHandle that can be used to retrieve any return result from the operation itself.

Source

pub fn run_until_complete(self)

Runs this executor until all tasks are complete.

Trait Implementations§

Source§

impl Default for SingleThreadExecutor

Source§

impl Drop for SingleThreadExecutor

Source§

fn drop(&mut self)

Executes the destructor for this type. 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> 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, 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.