Struct RemoteHandle

#[must_use = "dropping a remote handle cancels the underlying future"]
pub struct RemoteHandle<T> { /* private fields */ }

The handle to a remote future returned by remote_handle. When you drop this, the remote future will be woken up to be dropped by the executor.

Unwind safety

When the remote future panics, [Remote] will catch the unwind and transfer it to the thread where RemoteHandle is being awaited. This is good for the common case where [Remote] is spawned on a threadpool. It is unlikely that other code in the executor working thread shares mutable data with the spawned future and we preserve the executor from losing its working threads.

If you run the future locally and send the handle of to be awaited elsewhere, you must be careful with regard to unwind safety because the thread in which the future is polled will keep running after the panic and the thread running the [RemoteHandle] will unwind.

Implementations

impl<T> RemoteHandle<T>

fn forget(self)

Drops this handle without canceling the underlying future.

This method can be used if you want to drop the handle, but let the execution continue.

Trait Implementations

impl<T: 'static> Future for RemoteHandle<T>

type Output = T;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T>

impl<T: Debug> Debug for RemoteHandle<T>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<T> !RefUnwindSafe for RemoteHandle<T>

impl<T> !UnwindSafe for RemoteHandle<T>

impl<T> Freeze for RemoteHandle<T> where Receiver<Result<T, Box<dyn Any + Send>>>: Freeze,

impl<T> Send for RemoteHandle<T> where Receiver<Result<T, Box<dyn Any + Send>>>: Send,

impl<T> Sync for RemoteHandle<T> where Receiver<Result<T, Box<dyn Any + Send>>>: Sync,

impl<T> Unpin for RemoteHandle<T> where Receiver<Result<T, Box<dyn Any + Send>>>: Unpin,

impl<T> UnsafeUnpin for RemoteHandle<T> where Receiver<Result<T, Box<dyn Any + Send>>>: UnsafeUnpin,

Blanket Implementations

impl<F> IntoFuture for RemoteHandle<T> where F: Future,

type Output = <F as Future>::Output;
type IntoFuture = F;
fn into_future(self) -> <F as IntoFuture>::IntoFuture

impl<F, T, E> TryFuture for RemoteHandle<T> where F: Future<Output = Result<T, E>> + ?Sized,

type Ok = T;
type Error = E;
fn try_poll(self: Pin<&mut F>, cx: &mut Context<'_>) -> Poll<<F as Future>::Output>

impl<Fut> TryFutureExt for RemoteHandle<T> where Fut: TryFuture + ?Sized,

impl<T> Any for RemoteHandle<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for RemoteHandle<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for RemoteHandle<T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for RemoteHandle<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FutureExt for RemoteHandle<T> where T: Future + ?Sized,

impl<T, U> Into<U> for RemoteHandle<T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for RemoteHandle<T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for RemoteHandle<T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>