ExecutorHandle

Struct ExecutorHandle 

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

Handle task spawning and timer

Implementations§

Source§

impl ExecutorHandle

Source

pub async fn exit(&self) -> !

Exit event loop with exit code

Source

pub fn wait(&self, delay: Duration) -> TimerFuture<'_>

Create Future waiting for given duration.

Source

pub fn wait_deadline(&self, timestamp: u64) -> TimerFuture<'_>

Create Future waiting for given timestamp

Source

pub fn spawn<Fut>(&self, fut: Fut) -> Task<Fut::Output>
where Fut: Future + Send + 'static, Fut::Output: Send + 'static,

Spawn a new task, running on runtime thread

Because it can be called on outside of runtime thread, the Future and its output must be Send

Source

pub fn spawn_local<Fut>(&self, fut: Fut) -> Task<Fut::Output>
where Fut: Future + 'static, Fut::Output: 'static,

Spawn and run new task, on runtime thread.

Unlike ExecutorHandle::spawn this method check if this method called on runtime’s thread and will panic if it didn’t. Therefore the Future and its output does not need to be Send

Source

pub unsafe fn spawn_unchecked<Fut>(&self, fut: Fut) -> Task<Fut::Output>
where Fut: Future,

Spawn and run new task, without checking Future and its output’s bound.

§Safety

If Future and its output is

  1. not Send: Must be called on main thread.
  2. non ’static: References to Future must outlive.

Trait Implementations§

Source§

impl Debug for ExecutorHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> Is for T
where T: ?Sized,

Source§

type EqTo = T

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.