Trait mz_ore::channel::OneshotReceiverExt

source ·
pub trait OneshotReceiverExt<T> {
    // Required method
    fn with_guard<F>(self, guard: F) -> GuardedReceiver<F, T> 
       where F: FnMut(T);
}
Available on crate feature async only.
Expand description

Extensions for oneshot channel types.

Required Methods§

source

fn with_guard<F>(self, guard: F) -> GuardedReceiver<F, T>
where F: FnMut(T),

If the receiver is dropped without the value being observed, the provided closure will be called with the value that was left in the channel.

This is useful in cases where you want to cleanup resources if the receiver of this value has gone away. If the sender and receiver are running on separate threads, it’s possible for the sender to succeed, and for the receiver to be concurrently dropped, never realizing that it received a value.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> OneshotReceiverExt<T> for Receiver<T>

source§

fn with_guard<F>(self, guard: F) -> GuardedReceiver<F, T>
where F: FnMut(T),

Implementors§