Function ctrlc::set_handler_with_polling_rate [] [src]

pub fn set_handler_with_polling_rate<F>(user_handler: F, polling_rate: Duration) where F: Fn() -> () + 'static + Send

Sets up the signal handler for Ctrl-C using a custom polling rate. The polling rate is the amount of time the internal spinloop of CtrlC sleeps between iterations. Because condition variables are not safe to use inside a signal handler, CtrlC (from version 1.1.0) uses a spinloop and an atomic boolean instead.

Normally you should use set_handler instead, but if the default rate of 100 milliseconds is too fast or too slow for you, you can use this routine instead to set your own.

Example

ctrlc::set_handler_with_polling_rate(
    || println!("Hello world!"),
    Duration::from_millis(10)
);