Struct ckb_async_runtime::Handle
source · [−]pub struct Handle { /* private fields */ }
Expand description
Handle to the runtime.
Implementations
sourceimpl Handle
impl Handle
sourcepub fn enter<F, R>(&self, f: F) -> R where
F: FnOnce() -> R,
pub fn enter<F, R>(&self, f: F) -> R where
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
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl !UnwindSafe for Handle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more