LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
AI masks: the worker stops counting a job as pending before it replies
Claude6ea9b979c84e
diff --git a/crates/engine/src/segment/worker.rs b/crates/engine/src/segment/worker.rsindex 9ded0fbe0..b4a1eedfb 100644--- a/crates/engine/src/segment/worker.rs+++ b/crates/engine/src/segment/worker.rs@@ -210,8 +210,11 @@ fn run(rx: &mpsc::Receiver<Job>, shared: &Shared, idle: Duration) {}let Some(mut job) = queue.pop_front() else { continue };let is_detail = matches!(job.kind, Kind::Detail { .. });- let _done = Done(if is_detail { &shared.detail } else { &shared.pending });+ // counts the job as pending until just before its reply goes out: a caller woken by the+ // reply must not still see the worker busy with it+ let done = Done(if is_detail { &shared.detail } else { &shared.pending });if queue.iter().any(|later| supersedes(later, &job)) {+ drop(done);let _ = job.reply.send(Outcome { tag: job.tag, result: Ok(None), superseded: true });continue;}@@ -229,6 +232,7 @@ fn run(rx: &mpsc::Receiver<Job>, shared: &Shared, idle: Duration) {state.cache = None;}shared.loaded.store(state.model.is_some(), Ordering::SeqCst);+ drop(done);let _ = job.reply.send(Outcome { tag: job.tag, result, superseded: false });}}