pub trait BlockingRuntime: SharedRuntime {
// Required method
fn block_on<F: Future>(&self, f: F) -> Result<F::Output, Error>;
// Provided method
fn block_on_with_timeout<F: Future>(
&self,
f: F,
timeout: Duration,
) -> Result<F::Output, BlockOnTimeoutError> { ... }
}Expand description
Extension of SharedRuntime for runtimes that can block the current thread on a future.
Required Methods§
Provided Methods§
Sourcefn block_on_with_timeout<F: Future>(
&self,
f: F,
timeout: Duration,
) -> Result<F::Output, BlockOnTimeoutError>
fn block_on_with_timeout<F: Future>( &self, f: F, timeout: Duration, ) -> Result<F::Output, BlockOnTimeoutError>
Drives f to completion, blocking the current thread, but gives up once timeout
elapses.
This method drives the deadline on the same executor as block_on.
The bound is cooperative: the executor can only check the deadline when f yields.
A future that never yields, or that blocks the thread outside of .await, can run
past timeout before this method returns.
This method requires a build with unwinding panics. A panic = "abort" build cannot
catch the panic that a timerless runtime raises (see below), and aborts the process
instead of returning BlockOnTimeoutError::Io.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".