pub struct Handle { /* private fields */ }
Expand description
Handle to the runtime.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn drop_guard(&mut self)
pub fn drop_guard(&mut self)
Drop the guard
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>
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
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>
pub fn spawn_blocking<F, R>(&self, f: F) -> JoinHandle<R>
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
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handle
impl !RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl !UnwindSafe for Handle
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