#async-channel #mpsc #channel #async

channelmap

A DashMap wrapper over Tokio channels

4 releases (breaking)

Uses new Rust 2024

0.4.0 May 1, 2025
0.3.0 Apr 30, 2025
0.2.0 Apr 29, 2025
0.1.0 Apr 28, 2025

#522 in Concurrency

Download history 116/week @ 2025-04-23 243/week @ 2025-04-30 15/week @ 2025-05-07

374 downloads per month

MIT license

11KB
177 lines

ChannelMap is a DashMap wrapper over flume asynchronous/synchronous channels


ChannelMap

A DashMap wrapper over asynchronous flume channels. Provides a convenient way to send messages over named channels.

Example

use channelmap::ChannelMap;
use tokio::task::JoinSet;

#[tokio::main] // (or whatever executor you're using)
async fn main() {
    let channels = ChannelMap::new();
    let mut set = JoinSet::new();

    for i in 0..10 {
        let rx = channels.add(&i.to_string()).unwrap();
        set.spawn(async move {
            let msg = rx.recv_async().await.unwrap();
            assert_eq!(msg, "bar");
            println!("Channel {i} got message {msg}");
        });
    }

    for tx in channels.iter() {
        tx.send("bar").unwrap();
    }
    
    set.join_all().await;
}

License

Licensed under MIT.

Dependencies

~1.6–6.5MB
~43K SLoC