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

#1884 in Asynchronous

Download history 186/week @ 2024-08-14 173/week @ 2024-08-21 152/week @ 2024-08-28 88/week @ 2024-09-04 165/week @ 2024-09-11 133/week @ 2024-09-18 210/week @ 2024-09-25 96/week @ 2024-10-02 121/week @ 2024-10-09 200/week @ 2024-10-16 144/week @ 2024-10-23 162/week @ 2024-10-30 148/week @ 2024-11-06 115/week @ 2024-11-13 121/week @ 2024-11-20 204/week @ 2024-11-27

630 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

~355KB