Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 846 Bytes

README.md

File metadata and controls

36 lines (27 loc) · 846 Bytes

Async SPSC Channel

action badge


Wait-free(even without CAS), async, single-producer single-consumer channel.

Examples

The usage of this channel is almost the same as tokio's channel.

#[tokio::main]
async fn main() {
    let (mut tx, mut rx) = spsc::channel(128);

    tokio::spawn(async move {
        for i in 0..10 {
            if tx.send(i).await.is_err() {
                println!("receiver dropped");
                return;
            }
        }
    });

    while let Some(i) = rx.recv().await {
        println!("got = {}", i);
    }
}

License

Licensed under either of