Skip to content

Liyixin95/spsc-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages