pub struct Handle { /* private fields */ }Expand description
A handle to the runtime that can be cloned and sent across threads.
Right now the underlying work queue is thread-local, overtime there might also be a thread-local variant of the handel that can’t be sent to other threads.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn block_on<F>(&self, future: F) -> F::Output
pub fn block_on<F>(&self, future: F) -> F::Output
Run a future, blocking the current thread until its done.
The future might end up running on a different thread, and this thread might make progress on other futures before returning.
Sourcepub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
Spawn a future to run in the background. The future can make progress by any participating thread.
If the runtime doesn’t have any background threads, the JoinHandle should be polled/awaited explicitly.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Handle
impl !UnwindSafe for Handle
impl Freeze for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl UnsafeUnpin 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