diff options
| author | mo8it <mo8it@proton.me> | 2024-09-18 01:43:48 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-09-18 01:43:48 +0200 |
| commit | 89c40ba25672b2da17e2fcc5bc742462699d54dd (patch) | |
| tree | f46f89010e2cd19034db5c69d4dc5ffb6fb0f6c3 /src/watch/terminal_event.rs | |
| parent | e56ae6d65144d0a0bc8cc6759c89e59658a71497 (diff) | |
Optimize the file watcher
Diffstat (limited to 'src/watch/terminal_event.rs')
| -rw-r--r-- | src/watch/terminal_event.rs | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/watch/terminal_event.rs b/src/watch/terminal_event.rs index 2a1dfdc..050c4ac 100644 --- a/src/watch/terminal_event.rs +++ b/src/watch/terminal_event.rs @@ -1,31 +1,7 @@ use crossterm::event::{self, Event, KeyCode, KeyEventKind}; -use std::sync::{ - atomic::{AtomicBool, Ordering::Relaxed}, - mpsc::Sender, -}; +use std::sync::{atomic::Ordering::Relaxed, mpsc::Sender}; -use super::WatchEvent; - -static INPUT_PAUSED: AtomicBool = AtomicBool::new(false); - -// Private unit type to force using the constructor function. -#[must_use = "When the guard is dropped, the input is unpaused"] -pub struct InputPauseGuard(()); - -impl InputPauseGuard { - #[inline] - pub fn scoped_pause() -> Self { - INPUT_PAUSED.store(true, Relaxed); - Self(()) - } -} - -impl Drop for InputPauseGuard { - #[inline] - fn drop(&mut self) { - INPUT_PAUSED.store(false, Relaxed); - } -} +use super::{WatchEvent, EXERCISE_RUNNING}; pub enum InputEvent { Run, @@ -44,7 +20,7 @@ pub fn terminal_event_handler(sender: Sender<WatchEvent>, manual_run: bool) { KeyEventKind::Press => (), } - if INPUT_PAUSED.load(Relaxed) { + if EXERCISE_RUNNING.load(Relaxed) { continue; } |
