pub type OnSignalsRef<'a> = OnSignals<'a, HandleRef<'a>>;
Expand description
Alias for the common case where OnSignals is used with zx::HandleRef.
Aliased Type§
struct OnSignalsRef<'a> { /* private fields */ }
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
.