fparkan/vendor/flume/examples/async.rs
Valentin Popov 1b6a04ca55
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
2024-01-08 01:21:28 +04:00

22 lines
447 B
Rust

#[cfg(feature = "async")]
#[async_std::main]
async fn main() {
let (tx, rx) = flume::bounded(1);
let t = async_std::task::spawn(async move {
while let Ok(msg) = rx.recv_async().await {
println!("Received: {}", msg);
}
});
tx.send_async("Hello, world!").await.unwrap();
tx.send_async("How are you today?").await.unwrap();
drop(tx);
t.await;
}
#[cfg(not(feature = "async"))]
fn main() {}