Crates.io | fuze |
lib.rs | fuze |
version | 3.0.0 |
source | src |
created_at | 2021-07-15 15:01:03.184431 |
updated_at | 2021-07-22 10:29:50.865469 |
description | A mechanism to wait for a single signal which can be checked at any time |
homepage | https://github.com/passcod/superman/tree/main/fuze |
repository | https://github.com/passcod/superman/tree/main/fuze |
max_upload_size | |
id | 423125 |
size | 9,094 |
A mechanism to wait for a single signal which can be checked at any time.
A Fuze can be checked synchronously, and will show up as burnt only once it’s been burnt. It
can be awaited while it’s unburnt, and it can be Cloned and used without mut
at any time.
Useful for exit conditions and as a one-off no-payload channel.
use fuze::Fuze;
use async_std::task;
use std::time::Duration;
let f1 = Fuze::new();
let f2 = f1.clone();
task::block_on(async move {
println!("Halo!");
task::spawn(async move {
task::sleep(Duration::from_secs(1)).await;
f3.burn();
});
f2.wait().await;
println!("Adios!");
});