pub struct Remote { /* private fields */ }
Expand description
Handle to an event loop, used to construct I/O objects, send messages, and otherwise interact indirectly with the event loop itself.
Handles can be cloned, and when cloned they will still refer to the same underlying event loop.
Implementations§
Source§impl Remote
impl Remote
Sourcepub fn spawn<F, R>(&self, f: F)
pub fn spawn<F, R>(&self, f: F)
Spawns a new future into the event loop this remote is associated with.
This function takes a closure which is executed within the context of the I/O loop itself. The future returned by the closure will be scheduled on the event loop and run to completion.
Note that while the closure, F
, requires the Send
bound as it might
cross threads, the future R
does not.
§Panics
This method will not catch panics from polling the future f
. If
the future panics then it’s the responsibility of the caller to catch
that panic and handle it as appropriate.
Sourcepub fn handle(&self) -> Option<Handle>
pub fn handle(&self) -> Option<Handle>
Attempts to “promote” this remote to a handle, if possible.
This function is intended for structures which typically work through a
Remote
but want to optimize runtime when the remote doesn’t actually
leave the thread of the original reactor. This will attempt to return a
handle if the Remote
is on the same thread as the event loop and the
event loop is running.
If this Remote
has moved to a different thread or if the event loop is
running, then None
may be returned. If you need to guarantee access to
a Handle
, then you can call this function and fall back to using
spawn
above if it returns None
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Remote
impl !RefUnwindSafe for Remote
impl Send for Remote
impl Sync for Remote
impl Unpin for Remote
impl !UnwindSafe for Remote
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)