pub struct AgnosticExecutor { /* private fields */ }Expand description
An executor that can spawn futures. This can be freely stored anywhere you need, cloned, and be sent to other threads.
Implementations§
Source§impl AgnosticExecutor
impl AgnosticExecutor
Sourcepub fn spawn<F, T>(&self, future: F) -> JoinHandle<T> ⓘ
pub fn spawn<F, T>(&self, future: F) -> JoinHandle<T> ⓘ
Spawns a future on this executor.
Sourcepub fn spawn_blocking<F, T>(&self, task: F) -> JoinHandle<T> ⓘ
pub fn spawn_blocking<F, T>(&self, task: F) -> JoinHandle<T> ⓘ
Runs the provided closure, and when possible, it does it in a way that doesn’t block concurrent tasks.
Source§impl AgnosticExecutor
impl AgnosticExecutor
Sourcepub async fn sleep_millis(&self, duration: u64)
pub async fn sleep_millis(&self, duration: u64)
Returns a future that sleeps for a duration in milliseconds.
Sourcepub async fn timeout<T: Future>(
&self,
duration: Duration,
future: T,
) -> Result<T::Output, TimedOut>
pub async fn timeout<T: Future>( &self, duration: Duration, future: T, ) -> Result<T::Output, TimedOut>
Wraps a future in a timeout that expires after a duration if the provided future didn’t finish.
Sourcepub async fn timeout_millis<T: Future>(
&self,
duration: u64,
future: T,
) -> Result<T::Output, TimedOut>
pub async fn timeout_millis<T: Future>( &self, duration: u64, future: T, ) -> Result<T::Output, TimedOut>
Wraps a future in a timeout that expires after a duration in milliseconds if the provided future didn’t finish.
Sourcepub fn interval(&self, duration: Duration) -> Interval
pub fn interval(&self, duration: Duration) -> Interval
Creates a new Interval for a given duration.
Sourcepub fn interval_millis(&self, duration: u64) -> Interval
pub fn interval_millis(&self, duration: u64) -> Interval
Creates a new Interval for a given duration in milliseconds.
Trait Implementations§
Source§impl Clone for AgnosticExecutor
impl Clone for AgnosticExecutor
Source§fn clone(&self) -> AgnosticExecutor
fn clone(&self) -> AgnosticExecutor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AgnosticExecutor
impl RefUnwindSafe for AgnosticExecutor
impl Send for AgnosticExecutor
impl Sync for AgnosticExecutor
impl Unpin for AgnosticExecutor
impl UnwindSafe for AgnosticExecutor
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
Mutably borrows from an owned value. Read more