pub struct CtrlC;
Implementations
sourceimpl CtrlC
impl CtrlC
sourcepub fn set_handler<F>(user_handler: F) where
F: Fn() + 'static + Send,
pub fn set_handler<F>(user_handler: F) where
F: Fn() + 'static + Send,
Sets up the signal handler for Ctrl-C using default polling rate of 100ms.
Example
CtrlC::set_handler(|| println!("Hello world!"));
sourcepub fn set_handler_with_polling_rate<F>(user_handler: F, polling_rate: Duration) where
F: Fn() + 'static + Send,
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)
);
Auto Trait Implementations
impl RefUnwindSafe for CtrlC
impl Send for CtrlC
impl Sync for CtrlC
impl Unpin for CtrlC
impl UnwindSafe for CtrlC
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more