Struct ckb_async_runtime::Handle
source · pub struct Handle { /* private fields */ }
Expand description
Handle to the runtime.
Implementations§
source§impl Handle
impl Handle
sourcepub fn enter<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R,
pub fn enter<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R,
Enter the runtime context. This allows you to construct types that must
have an executor available on creation such as tokio::time::Sleep
or tokio::net::TcpStream
.
It will also allow you to call methods such as tokio::spawn
.
sourcepub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>where
F: Future + Send + 'static,
F::Output: Send + 'static,
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>where
F: Future + Send + 'static,
F::Output: Send + 'static,
Spawns a future onto the runtime.
This spawns the given future onto the runtime’s executor
sourcepub fn block_on<F: Future>(&self, future: F) -> F::Output
pub fn block_on<F: Future>(&self, future: F) -> F::Output
Run a future to completion on the Tokio runtime from a synchronous context.
sourcepub fn spawn_blocking<F, R>(&self, f: F) -> JoinHandle<R>where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
pub fn spawn_blocking<F, R>(&self, f: F) -> JoinHandle<R>where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
Spawns a future onto the runtime blocking pool.
This spawns the given future onto the runtime’s blocking executor
sourcepub fn into_inner(self) -> TokioHandle
pub fn into_inner(self) -> TokioHandle
Transform to inner tokio handler