From 7c6841782d36faacc2aa3616dc3ed1b9403fa26e Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 2 Nov 2023 10:45:11 +0800 Subject: refactor: improve code quanity (#197) - move model_info.rs/message.rs to clients/ - rename SharedConfig to GlobalConfig --- src/repl/abort.rs | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 src/repl/abort.rs (limited to 'src/repl/abort.rs') diff --git a/src/repl/abort.rs b/src/repl/abort.rs deleted file mode 100644 index af58b35..0000000 --- a/src/repl/abort.rs +++ /dev/null @@ -1,55 +0,0 @@ -use std::sync::{ - atomic::{AtomicBool, Ordering}, - Arc, -}; - -pub type AbortSignal = Arc; - -pub struct AbortSignalInner { - ctrlc: AtomicBool, - ctrld: AtomicBool, -} - -pub fn create_abort_signal() -> AbortSignal { - AbortSignalInner::new() -} - -impl AbortSignalInner { - pub fn new() -> AbortSignal { - Arc::new(Self { - ctrlc: AtomicBool::new(false), - ctrld: AtomicBool::new(false), - }) - } - - pub fn aborted(&self) -> bool { - if self.aborted_ctrlc() { - return true; - } - if self.aborted_ctrld() { - return true; - } - false - } - - pub fn aborted_ctrlc(&self) -> bool { - self.ctrlc.load(Ordering::SeqCst) - } - - pub fn aborted_ctrld(&self) -> bool { - self.ctrld.load(Ordering::SeqCst) - } - - pub fn reset(&self) { - self.ctrlc.store(false, Ordering::SeqCst); - self.ctrld.store(false, Ordering::SeqCst); - } - - pub fn set_ctrlc(&self) { - self.ctrlc.store(true, Ordering::SeqCst); - } - - pub fn set_ctrld(&self) { - self.ctrld.store(true, Ordering::SeqCst); - } -} -- cgit v1.2.3