Crates.io | interruptor |
lib.rs | interruptor |
version | 0.1.1 |
source | src |
created_at | 2021-11-03 16:53:19.789266 |
updated_at | 2022-04-11 17:21:02.627859 |
description | Collection of functions generating Unix process signal receivers for use in the Crossbeam Channel select! macro. |
homepage | |
repository | https://github.com/zduny/interruptor |
max_upload_size | |
id | 476254 |
size | 17,010 |
Collection of functions generating Unix process signal receivers
for use in the Crossbeam Channel select!
macro.
use std::time::Duration;
use crossbeam_channel::{select, tick};
use interruptor::interruption_or_termination;
fn main() {
let tick = tick(Duration::from_secs(1));
let stop = interruption_or_termination();
loop {
select! {
recv(tick) -> _ => println!("Running!"),
recv(stop) -> _ => break,
}
};
}