Type Alias OnSignalsRef

Source
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>

Source

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.

Source

pub fn take_handle(self) -> H
where H: HandleBased,

Takes the handle.

Source

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>

Source§

fn as_handle_ref(&self) -> HandleRef<'_>

Get a reference to the handle. One important use of such a reference is for object_wait_many.
Source§

fn raw_handle(&self) -> u32

Interpret the reference as a raw handle (an integer type). Two distinct handles will have different raw values (so it can perhaps be used as a key in a data structure).
Source§

fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>

Set and clear userspace-accessible signal bits on an object. Wraps the zx_object_signal syscall.
Source§

fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> Result<Signals, Status>

Waits on a handle. Wraps the zx_object_wait_one syscall.
Source§

fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>

Causes packet delivery on the given port when the object changes state and matches signals. zx_object_wait_async syscall.
Source§

fn get_name(&self) -> Result<Name, Status>

Get the Property::NAME property for this object. Read more
Source§

fn set_name(&self, name: &Name) -> Result<(), Status>

Set the Property::NAME property for this object. Read more
Source§

fn basic_info(&self) -> Result<HandleBasicInfo, Status>

Wraps the zx_object_get_info syscall for the ZX_INFO_HANDLE_BASIC topic.
Source§

fn count_info(&self) -> Result<HandleCountInfo, Status>

Wraps the zx_object_get_info syscall for the ZX_INFO_HANDLE_COUNT topic.
Source§

fn get_koid(&self) -> Result<Koid, Status>

Returns the koid (kernel object ID) for this handle.
Source§

impl<H: AsHandleRef> AsRef<H> for OnSignals<'_, H>

Source§

fn as_ref(&self) -> &H

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<H: AsHandleRef> Debug for OnSignals<'_, H>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<H: AsHandleRef> Drop for OnSignals<'_, H>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<H: AsHandleRef + Unpin> Future for OnSignals<'_, H>

Source§

type Output = Result<Signals, Status>

The type of value produced on completion.
Source§

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

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more