| Crates.io | will_exit |
| lib.rs | will_exit |
| version | 0.3.3 |
| created_at | 2022-01-03 03:34:30.127305+00 |
| updated_at | 2023-05-12 02:05:07.665484+00 |
| description | work on program will exit |
| homepage | |
| repository | https://github.com/rise0chen/will_exit.git |
| max_upload_size | |
| id | 506864 |
| size | 15,062 |
use core::time::Duration;
use std::thread;
fn main() {
will_exit::init(2000).unwrap();
std::panic::set_hook(Box::new(|info| {
println!("{}", info);
will_exit::exit(-1);
}));
thread::spawn(|| {
thread::sleep(Duration::from_secs(6));
will_exit::exit();
});
loop {
if will_exit::will_exit() {
break;
}
thread::sleep(Duration::from_millis(100));
}
println!("exit");
}