diff options
121 files changed, 25246 insertions, 25249 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index a9c40cf5..bf7d5340 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,4 @@ { "editor.formatOnSave": true, "workbench.settings.enableNaturalLanguageSearch": false, - "telemetry.enableTelemetry": false, }
\ No newline at end of file diff --git a/asyncgit/src/asyncjob/mod.rs b/asyncgit/src/asyncjob/mod.rs index 3b48787c..161df802 100644 --- a/asyncgit/src/asyncjob/mod.rs +++ b/asyncgit/src/asyncjob/mod.rs @@ -8,202 +8,202 @@ use std::sync::{Arc, Mutex}; /// trait that defines an async task we can run on a threadpool pub trait AsyncJob: Send + Sync + Clone { - /// can run a synchronous time intensive task - fn run(&mut self); + /// can run a synchronous time intensive task + fn run(&mut self); } /// Abstraction for a FIFO task queue that will only queue up **one** `next` job. /// It keeps overwriting the next job until it is actually taken to be processed #[derive(Debug, Clone)] pub struct AsyncSingleJob<J: AsyncJob, T: Copy + Send + 'static> { - next: Arc<Mutex<Option<J>>>, - last: Arc<Mutex<Option<J>>>, - sender: Sender<T>, - pending: Arc<Mutex<()>>, - notification: T, + next: Arc<Mutex<Option<J>>>, + last: Arc<Mutex<Option<J>>>, + sender: Sender<T>, + pending: Arc<Mutex<()>>, + notification: T, } impl<J: 'static + AsyncJob, T: Copy + Send + 'static> - AsyncSingleJob<J, T> + AsyncSingleJob<J, T> { - /// - pub fn new(sender: Sender<T>, value: T) -> Self { - Self { - next: Arc::new(Mutex::new(None)), - last: Arc::new(Mutex::new(None)), - pending: Arc::new(Mutex::new(())), - notification: value, - sender, - } - } - - /// - pub fn is_pending(&self) -> bool { - self.pending.try_lock().is_err() - } - - /// makes sure `next` is cleared and returns `true` if it actually canceled something - pub fn cancel(&mut self) -> bool { - if let Ok(mut next) = self.next.lock() { - if next.is_some() { - *next = None; - return true; - } - } - - false - } - - /// take out last finished job - pub fn take_last(&self) -> Option<J> { - if let Ok(mut last) = self.last.lock() { - last.take() - } else { - None - } - } - - /// spawns `t |