pub struct EHandle { /* private fields */ }
Expand description
A handle to an executor.
Implementations§
Source§impl EHandle
impl EHandle
Sourcepub fn local() -> Self
pub fn local() -> Self
Returns the thread-local executor.
§Panics
If called outside the context of an active async executor.
Sourcepub fn global_scope(&self) -> &ScopeHandle
pub fn global_scope(&self) -> &ScopeHandle
The root scope of the executor.
This can be used to spawn tasks that live as long as the executor, and to create shorter-lived child scopes.
Most users should create an owned scope with
Scope::new
instead of using this method.
Sourcepub fn port(&self) -> &Port
pub fn port(&self) -> &Port
Get a reference to the Fuchsia zx::Port
being used to listen for events.
Sourcepub fn register_receiver<T>(&self, receiver: Arc<T>) -> ReceiverRegistration<T>where
T: PacketReceiver,
pub fn register_receiver<T>(&self, receiver: Arc<T>) -> ReceiverRegistration<T>where
T: PacketReceiver,
Registers a PacketReceiver
with the executor and returns a registration.
The PacketReceiver
will be deregistered when the Registration
is dropped.
Sourcepub fn spawn_detached(&self, future: impl Future<Output = ()> + Send + 'static)
pub fn spawn_detached(&self, future: impl Future<Output = ()> + Send + 'static)
Spawn a new task to be run on this executor.
Tasks spawned using this method must be thread-safe (implement the Send
trait), as they
may be run on either a singlethreaded or multithreaded executor.
Sourcepub fn spawn_local_detached(&self, future: impl Future<Output = ()> + 'static)
pub fn spawn_local_detached(&self, future: impl Future<Output = ()> + 'static)
Spawn a new task to be run on this executor.
This is similar to the spawn_detached
method, but tasks spawned using this method do not
have to be threads-safe (implement the Send
trait). In return, this method requires that
this executor is a LocalExecutor.
Sourcepub fn poll_tasks(&self, callback: impl FnOnce())
pub fn poll_tasks(&self, callback: impl FnOnce())
Calls callback
in the context of the executor and then polls (a limited number of) tasks
that are ready to run. If tasks remain ready and no other threads are running, a thread
will be woken. This can end up being a performance win in the case that the queue can be
cleared without needing to wake any other thread.
§Panics
If called on a single-threaded executor or if this thread is a thread managed by the executor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EHandle
impl !RefUnwindSafe for EHandle
impl Send for EHandle
impl Sync for EHandle
impl Unpin for EHandle
impl !UnwindSafe for EHandle
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
)