diff --git a/crates/notebook/src/background.rs b/crates/notebook/src/background.rs index 6802c83a324026be0e39500ce01b10801ee95b77..10bff93ca3c80f474c459d65394677662a07816c 100644 --- a/crates/notebook/src/background.rs +++ b/crates/notebook/src/background.rs @@ -508,13 +508,11 @@ impl Background { self.0.signal.wake(); } - /// Stops for good, waiting for the step in flight, so that no replica stays open and no - /// watch holds the notebook's folder. + /// Stops future checks; native threads finish the current step before returning. pub fn stop(&self) { self.0.signal.stopped.store(true, Ordering::Release); self.0.signal.wake(); let thread = self.1.lock().ok().and_then(|mut thread| thread.take()); - // In the browser no step is in flight while another task runs. #[cfg(not(target_arch = "wasm32"))] if let Some(thread) = thread { let _ = thread.join(); diff --git a/crates/notebook/src/session.rs b/crates/notebook/src/session.rs index 5ea758ba37771e6328defdd3dff9967840faac23..b3dab38d7798a51b8a879988ab11ea7f1d8be8ba 100644 --- a/crates/notebook/src/session.rs +++ b/crates/notebook/src/session.rs @@ -2390,9 +2390,8 @@ impl Section { &self.replica } - /// Waits for the in-flight operation and callback before releasing the replica. - /// Dropping instead requests cancellation without waiting; the worker retains - /// cache ownership until that operation finishes. Remote calls must be bounded. + /// Stops future sync steps; native threads finish the current operation before returning. + /// The worker retains cache ownership until its in-flight operation finishes. pub fn close(mut self) -> Result<()> { match self.worker.take() { Some(worker) => worker.stop(), diff --git a/crates/notebook/src/worker.rs b/crates/notebook/src/worker.rs index c47645d84d9c68c6d060b252dc7f93ee0492e961..6d3028472385017628f106a2d8ec58c542b05798 100644 --- a/crates/notebook/src/worker.rs +++ b/crates/notebook/src/worker.rs @@ -79,7 +79,7 @@ impl Signal { } /// Owns automatic reconciliation. Dropping requests cancellation without blocking. -/// The in-flight sync step finishes before ownership is released; `stop` waits for it. +/// The in-flight sync step retains cache ownership until it finishes. pub struct SyncWorker { signal: Arc, thread: Option>>, @@ -116,14 +116,13 @@ impl SyncWorker { self.signal.wake(); } - /// Cancels future steps and waits for the current step and callback to finish. + /// Cancels future steps; native threads finish the current step and callback before returning. /// A stopped worker leaves pending edits and uncertain attempts in the cache. /// Call outside the worker's own callback, which cannot join its calling thread. pub fn stop(mut self) -> Result<()> { self.signal.stopped.store(true, Ordering::Release); self.signal.wake(); let thread = self.thread.take().expect("Worker owns its thread"); - // In the browser no step is in flight outside the worker's own callback. #[cfg(target_arch = "wasm32")] return thread.finished().unwrap_or(Ok(())); #[cfg(not(target_arch = "wasm32"))]