2 unstable releases

0.2.3 Jun 21, 2022
0.2.2 Jun 20, 2022
0.2.1 Sep 14, 2020
0.2.0 Sep 14, 2020
0.1.0 Sep 13, 2020

#1627 in Asynchronous

Download history 22/week @ 2023-12-03 62/week @ 2023-12-10 56/week @ 2023-12-17 42/week @ 2023-12-24 33/week @ 2023-12-31 54/week @ 2024-01-07 41/week @ 2024-01-14 58/week @ 2024-01-21 83/week @ 2024-01-28 50/week @ 2024-02-04 68/week @ 2024-02-11 86/week @ 2024-02-18 66/week @ 2024-02-25 88/week @ 2024-03-03 127/week @ 2024-03-10 74/week @ 2024-03-17

358 downloads per month

Apache-2.0

17KB
318 lines

barrage

A simple async broadcast channel. It is runtime agnostic and can be used from any executor. It can also operate synchronously.

Example

#[tokio::main]
async fn main() {
    let (tx, rx) = barrage::unbounded();
    let rx2 = rx.clone();
    tx.send_async("Hello!").await.unwrap();
    assert_eq!(rx.recv_async().await, Ok("Hello!"));
    assert_eq!(rx2.recv_async().await, Ok("Hello!"));
}

lib.rs:

Barrage - an asynchronous broadcast channel. Each message sent will be received by every receiver. When the channel reaches its cap, send operations will block, wait, or fail (depending on which type of send was chosen). Cloned receivers will only receive messages sent after they are cloned.

Example


let (tx, rx1) = barrage::unbounded();
let rx2 = rx1.clone();
tx.send("Hello!");
let rx3 = rx1.clone();
assert_eq!(rx1.recv(), Ok("Hello!"));
assert_eq!(rx2.recv(), Ok("Hello!"));
assert_eq!(rx3.try_recv(), Ok(None));

Dependencies

~345KB