denyhosts/clamav/libclamav_rust/.cargo/vendor/flume/examples/async.rs

22 lines
447 B
Rust
Raw Permalink Normal View History

2023-01-14 18:28:39 +08:00
#[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() {}