diff options
| author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-16 16:42:50 +0530 |
|---|---|---|
| committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-16 21:41:56 +0530 |
| commit | 2038947a14d32d89da2bdbcaa1381c3015ac9c7a (patch) | |
| tree | 5a332470e32b380816098594a89d3c3db1f6eb53 /src/common/command_is_executing.rs | |
| parent | handle error on termios initialization (#511) (diff) | |
| download | sl0ppij-2038947a14d32d89da2bdbcaa1381c3015ac9c7a.tar.gz sl0ppij-2038947a14d32d89da2bdbcaa1381c3015ac9c7a.tar.xz sl0ppij-2038947a14d32d89da2bdbcaa1381c3015ac9c7a.zip | |
Big refactor: separate crates for client, server and utilities
Diffstat (limited to 'src/common/command_is_executing.rs')
| -rw-r--r-- | src/common/command_is_executing.rs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/common/command_is_executing.rs b/src/common/command_is_executing.rs deleted file mode 100644 index ad032557..00000000 --- a/src/common/command_is_executing.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![allow(clippy::mutex_atomic)] -use std::sync::{Arc, Condvar, Mutex}; - -#[derive(Clone)] -pub struct CommandIsExecuting { - input_thread: Arc<(Mutex<bool>, Condvar)>, -} - -impl CommandIsExecuting { - pub fn new() -> Self { - CommandIsExecuting { - input_thread: Arc::new((Mutex::new(false), Condvar::new())), - } - } - pub fn blocking_input_thread(&mut self) { - let (lock, _cvar) = &*self.input_thread; - let mut input_thread = lock.lock().unwrap(); - *input_thread = true; - } - pub fn unblock_input_thread(&mut self) { - let (lock, cvar) = &*self.input_thread; - let mut input_thread = lock.lock().unwrap(); - *input_thread = false; - cvar.notify_all(); - } - pub fn wait_until_input_thread_is_unblocked(&self) { - let (lock, cvar) = &*self.input_thread; - let mut input_thread = lock.lock().unwrap(); - while *input_thread { - input_thread = cvar.wait(input_thread).unwrap(); - } - } -} |
