pub struct OnSignals<'a, H: AsHandleRef> { /* private fields */ }
Expand description
A future that completes when some set of signals become available on a Handle.
Implementations§
Source§impl<'a, H: AsHandleRef + 'a> OnSignals<'a, H>
impl<'a, H: AsHandleRef + 'a> OnSignals<'a, H>
Sourcepub fn new(handle: H, signals: Signals) -> Self
pub fn new(handle: H, signals: Signals) -> Self
Creates a new OnSignals
object which will receive notifications when
any signals in signals
occur on handle
.
Sourcepub fn take_handle(self) -> Hwhere
H: HandleBased,
pub fn take_handle(self) -> Hwhere
H: HandleBased,
Takes the handle.
Sourcepub fn extend_lifetime(self) -> LeakedOnSignals
pub fn extend_lifetime(self) -> LeakedOnSignals
This function allows the OnSignals
object to live for the 'static
lifetime, at the cost
of disabling automatic cleanup of the port wait.
WARNING: Do not use unless you can guarantee that either:
- The future is not dropped before it completes, or
- The handle is dropped without creating additional OnSignals futures for it.
Creating an OnSignals calls zx_object_wait_async, which consumes a small amount of kernel resources. Dropping the OnSignals calls zx_port_cancel to clean up. But calling extend_lifetime disables this cleanup, since the zx_port_wait call requires a reference to the handle. The port registration can also be cleaned up by closing the handle or by waiting for the signal to be triggered. But if neither of these happens, the registration is leaked. This wastes kernel memory and the kernel will eventually kill your process to force a cleanup.
Note that OnSignals
will not fire if the handle that was used to create it is dropped or
transferred to another process.
Trait Implementations§
Source§impl<H: AsHandleRef> AsHandleRef for OnSignals<'_, H>
impl<H: AsHandleRef> AsHandleRef for OnSignals<'_, H>
Source§fn as_handle_ref(&self) -> HandleRef<'_>
fn as_handle_ref(&self) -> HandleRef<'_>
object_wait_many
.Source§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
Source§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
Source§fn wait_handle(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> Result<Signals, Status>
Source§fn wait_async_handle(
&self,
port: &Port,
key: u64,
signals: Signals,
options: WaitAsyncOpts,
) -> Result<(), Status>
fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>
Source§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
Source§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
Source§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
Source§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
Source§impl<H: AsHandleRef> AsRef<H> for OnSignals<'_, H>
impl<H: AsHandleRef> AsRef<H> for OnSignals<'_, H>
Source§impl<H: AsHandleRef> Debug for OnSignals<'_, H>
impl<H: AsHandleRef> Debug for OnSignals<'_, H>
Source§impl<H: AsHandleRef> Drop for OnSignals<'_, H>
impl<H: AsHandleRef> Drop for OnSignals<'_, H>
Auto Trait Implementations§
impl<'a, H> Freeze for OnSignals<'a, H>where
H: Freeze,
impl<'a, H> !RefUnwindSafe for OnSignals<'a, H>
impl<'a, H> Send for OnSignals<'a, H>
impl<'a, H> Sync for OnSignals<'a, H>where
H: Sync,
impl<'a, H> Unpin for OnSignals<'a, H>where
H: Unpin,
impl<'a, H> !UnwindSafe for OnSignals<'a, H>
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read more§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read more§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<F> TimeoutExt for Fwhere
F: Future,
impl<F> TimeoutExt for Fwhere
F: Future,
Source§fn on_timeout<WT, OT>(self, time: WT, on_timeout: OT) -> OnTimeout<Self, OT> ⓘ
fn on_timeout<WT, OT>(self, time: WT, on_timeout: OT) -> OnTimeout<Self, OT> ⓘ
on_timeout
to produce a result
when the timeout occurs.Source§fn on_stalled<OS>(
self,
timeout: Duration,
on_stalled: OS,
) -> OnStalled<Self, OS> ⓘ
fn on_stalled<OS>( self, timeout: Duration, on_stalled: OS, ) -> OnStalled<Self, OS> ⓘ
on_stalled
to produce a result
when the future hasn’t been otherwise polled within the timeout
.
This is a heuristic - spurious wakeups will keep the detection from triggering,
and moving all work to external tasks or threads with force the triggering early.§impl<F, T, E> TryFuture for F
impl<F, T, E> TryFuture for F
§impl<Fut> TryFutureExt for Futwhere
Fut: TryFuture + ?Sized,
impl<Fut> TryFutureExt for Futwhere
Fut: TryFuture + ?Sized,
§fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>where
Self::Ok: Sink<Item, Error = Self::Error>,
Self: Sized,
fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>where
Self::Ok: Sink<Item, Error = Self::Error>,
Self: Sized,
Sink
]. Read more