Unified · Split
| @@ -14,13 +14,13 @@ mod _impl { · 13 unmodified lines | |||
| 14 | 14 | ||
| 15 | /// Initialize a signal handler to listen to SIGINT and SIGTERM and trigger our [`trigger()`][super::trigger()] that way. | 15 | /// Initialize a signal handler to listen to SIGINT and SIGTERM and trigger our [`trigger()`][super::trigger()] that way. |
| 16 | /// | 16 | /// |
| 17 | /// When `Ctrl+C` is pressed, a message will be sent to `message_channel` to inform the user about it being registered, after all | 17 | /// When `Ctrl+C` is pressed, a message will be sent to `out` to inform the user about it being registered, after all |
| 18 | /// actually responding to it is implementation dependent and might thus take some time (or not work at all). | 18 | /// actually responding to it is implementation dependent and might thus take some time (or not work at all). |
| 19 | /// | 19 | /// |
| 20 | /// # Note | 20 | /// # Note |
| 21 | /// | 21 | /// |
| 22 | /// This implementation is available only with the **interrupt-handler** feature toggle with the **disable-interrupts** feature disabled. | 22 | /// This implementation is available only with the **interrupt-handler** feature toggle with the **disable-interrupts** feature disabled. |
| 23 | pub fn init_handler(mut message_channel: impl io::Write + Send + 'static) { | 23 | pub fn init_handler(mut out: impl io::Write + Send + 'static) { |
| 24 | ctrlc::set_handler(move || { | 24 | ctrlc::set_handler(move || { |
| 25 | const MESSAGES: &[&str] = &[ | 25 | const MESSAGES: &[&str] = &[ |
| 26 | "interrupt requested", | 26 | "interrupt requested", |
| @@ -34,7 +34,7 @@ mod _impl { · 7 unmodified lines | |||
| 34 | } | 34 | } |
| 35 | let msg_idx = CURRENT_MESSAGE.fetch_add(1, Ordering::Relaxed); | 35 | let msg_idx = CURRENT_MESSAGE.fetch_add(1, Ordering::Relaxed); |
| 36 | super::IS_INTERRUPTED.store(true, Ordering::Relaxed); | 36 | super::IS_INTERRUPTED.store(true, Ordering::Relaxed); |
| 37 | writeln!(message_channel, "{}", MESSAGES[msg_idx % MESSAGES.len()]).ok(); | 37 | writeln!(out, "{}", MESSAGES[msg_idx % MESSAGES.len()]).ok(); |
| 38 | }) | 38 | }) |
| 39 | .expect("it is up to the application to ensure only one interrupt handler is installed, and this function is called only once.") | 39 | .expect("it is up to the application to ensure only one interrupt handler is installed, and this function is called only once.") |
| 40 | } | 40 | } |
| @@ -48,7 +48,7 @@ mod _impl { · 7 unmodified lines | |||
| 48 | use std::io; | 48 | use std::io; |
| 49 | 49 | ||
| 50 | /// Does nothing, as the **disable-interrupts** feature is enabled while the **interrupt-handler** feature is not present. | 50 | /// Does nothing, as the **disable-interrupts** feature is enabled while the **interrupt-handler** feature is not present. |
| 51 | pub fn init_handler(_message_channel: impl io::Write + Send + 'static) {} | 51 | pub fn init_handler(_out: impl io::Write + Send + 'static) {} |
| 52 | } | 52 | } |
| 53 | pub use _impl::init_handler; | 53 | pub use _impl::init_handler; |
| 54 | 54 | ||