Skip to main content

event_queue

Function event_queue 

Source
pub fn event_queue(max_tokens: usize) -> (Notifier, Poller)
Expand description

Create a notification channel with capacity for max_tokens unique tokens.

Returns a (Notifier, Poller) pair. The Notifier is cloneable for multiple producers. The Poller is single-consumer.

The underlying MPSC queue is sized to max_tokens — since the per-token dedup flag prevents duplicates, the queue can never overflow.

§Panics

Panics if max_tokens is 0.

§Examples

use nexus_notify::{event_queue, Token};

let (notifier, poller) = event_queue(128);
let token = Token::new(42);

notifier.notify(token).unwrap();