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

#1921 in Asynchronous

Download history 71/week @ 2024-04-11 82/week @ 2024-04-18 75/week @ 2024-04-25 62/week @ 2024-05-02 55/week @ 2024-05-09 56/week @ 2024-05-16 52/week @ 2024-05-23 67/week @ 2024-05-30 82/week @ 2024-06-06 136/week @ 2024-06-13 141/week @ 2024-06-20 73/week @ 2024-06-27 86/week @ 2024-07-04 172/week @ 2024-07-11 187/week @ 2024-07-18 213/week @ 2024-07-25

667 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