pub struct UserAnchor<U> { /* private fields */ }Expand description
Non-owning weak capability to the user lane (address-table
endpoint). Holds no liveness: the lane closes when the last counting
UserSender drops even while anchors are held. Every delivery first
atomically acquires a temporary live UserSender, so a delivery racing
the last sender drop either linearizes entirely before UserLaneClosed
or fails with its payload entirely after.
Under cfg(loom) the anchor holds a strong Arc instead of a Weak
(loom’s Arc has no downgrade): the semantic liveness is governed by
the senders counter, NOT the strong count, so the model stays faithful
— the strong-ref distinction is pure memory reclamation, covered on
hardware by tests/leak.rs.
Implementations§
Source§impl<U> UserAnchor<U>
impl<U> UserAnchor<U>
Sourcepub fn upgrade(&self) -> Option<UserSender<U>>
pub fn upgrade(&self) -> Option<UserSender<U>>
Acquire a temporary live UserSender iff the lane is still open.
The liveness increment is CONDITIONAL and atomic — one read-modify- write loop over the live-sender count that succeeds only while the count is nonzero. It never increments zero, so it can never resurrect a closed lane; a last-sender drop racing this upgrade is caught by the RMW reading zero, and the upgrade then fails with no side effect. The returned sender counts as live until dropped — held across an async send, released on success, error, or cancellation.
Sourcepub async fn send(&self, item: U) -> Result<(), UserClosed<U>>
pub async fn send(&self, item: U) -> Result<(), UserClosed<U>>
Enqueue a user message through a temporary live sender, awaiting capacity (backpressure). The temporary sender stays alive across the await — the lane cannot close while the delivery is in flight — and is dropped on success, error, or future cancellation, releasing its temporary liveness.
§Errors
Returns UserClosed carrying item if the lane is closed (no
live counting sender, or the consumer is gone).
Sourcepub fn try_send(&self, item: U) -> Result<(), TrySendError<U>>
pub fn try_send(&self, item: U) -> Result<(), TrySendError<U>>
Enqueue a user message without blocking, through a temporary live sender.
§Errors
TrySendError::Closed carrying item if the lane is closed (no
live counting sender, or the consumer is gone);
TrySendError::Full if the lane is at capacity.