8 releases

0.3.3 May 12, 2023
0.3.2 May 10, 2023
0.3.1 Apr 26, 2023
0.2.0 Apr 25, 2023
0.1.1 Jan 3, 2022

#1274 in Rust patterns

Download history 18/week @ 2024-09-24 2/week @ 2024-10-01

81 downloads per month
Used in daemon_ctrl

Custom license

7KB

will_exit

Usage

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");
}

Dependencies

~120KB