pub struct Receiver { /* private fields */ }Expand description
The consuming half of a session: the only way to observe completions.
Not clonable. The ordering the completion ring promises – every entry of one enumeration before its terminal – is a statement about one observer, and two receivers racing on the same ring would each see an arbitrary subsequence of it.
Dropping the receiver abandons the session: the session stops accepting enumerations and releases the ones it is carrying, without delivering any terminal outcome, because no observer remains to owe one to.
Implementations§
Source§impl Receiver
impl Receiver
Sourcepub fn try_recv(&self) -> Option<Completion>
pub fn try_recv(&self) -> Option<Completion>
Take the next record if one is already queued.
Sourcepub fn recv(&self) -> Option<Completion>
pub fn recv(&self) -> Option<Completion>
Block until a record is available, or until the stream ends.
Returns None only when nothing is queued, no session handle remains,
and no enumeration is still outstanding.
Sourcepub fn recv_timeout(&self, timeout: Duration) -> Option<Completion>
pub fn recv_timeout(&self, timeout: Duration) -> Option<Completion>
Block for at most timeout.
Returns None on timeout as well as at the end of the stream; a caller
that must tell them apart can check
is_disconnected.
Sourcepub fn doorbell(&self) -> Result<BorrowedHandle<'_>>
pub fn doorbell(&self) -> Result<BorrowedHandle<'_>>
A manual-reset event, signalled exactly while this receiver has something to take.
This is what lets a client integrate with its own thread pool instead of
dedicating a thread to recv: wait on the handle, then
drain with try_recv until it yields None. It stays
signalled once the stream has ended, so a waiter learns about that too.
The event is created on the first call, so a client that never asks for it pays for no kernel object. The borrow is deliberate: the event belongs to the ring and must not be closed by a caller.
§Errors
Returns the error from CreateEventW on the first call.
Sourcepub fn doorbell_owned(&self) -> Result<OwnedHandle>
pub fn doorbell_owned(&self) -> Result<OwnedHandle>
Sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Whether the stream has ended.