Add real pause, desktop notifications, undo, accessibility, CLI watch
This commit is contained in:
@@ -32,17 +32,32 @@ pub struct BatchResult {
|
||||
|
||||
pub struct PipelineExecutor {
|
||||
cancel_flag: Arc<AtomicBool>,
|
||||
pause_flag: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl PipelineExecutor {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
cancel_flag: Arc::new(AtomicBool::new(false)),
|
||||
pause_flag: Arc::new(AtomicBool::new(false)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_cancel(cancel_flag: Arc<AtomicBool>) -> Self {
|
||||
Self { cancel_flag }
|
||||
Self {
|
||||
cancel_flag,
|
||||
pause_flag: Arc::new(AtomicBool::new(false)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_cancel_and_pause(
|
||||
cancel_flag: Arc<AtomicBool>,
|
||||
pause_flag: Arc<AtomicBool>,
|
||||
) -> Self {
|
||||
Self {
|
||||
cancel_flag,
|
||||
pause_flag,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn execute<F>(&self, job: &ProcessingJob, mut on_progress: F) -> Result<BatchResult>
|
||||
@@ -71,6 +86,18 @@ impl PipelineExecutor {
|
||||
break;
|
||||
}
|
||||
|
||||
// Wait while paused (check every 100ms)
|
||||
while self.pause_flag.load(Ordering::Relaxed) {
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
if self.cancel_flag.load(Ordering::Relaxed) {
|
||||
result.cancelled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if result.cancelled {
|
||||
break;
|
||||
}
|
||||
|
||||
let file_name = source
|
||||
.path
|
||||
.file_name()
|
||||
|
||||
Reference in New Issue
Block a user