From 65818d6f3088ab1190fbcfdf8db8cdcc17786f6c Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 21 Nov 2026 23:23:17 +0700 Subject: [PATCH] shell-w19: net change of 2 commits - shell-w19: written from its sheet - shell-w19: repair 1 --- apps/vectorcraft-web/src/locks.rs | 8 ++++---- crates/ui-egui/src/thumb_worker.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/vectorcraft-web/src/locks.rs b/apps/vectorcraft-web/src/locks.rs index dffd87868a..334f131448 100644 --- a/apps/vectorcraft-web/src/locks.rs +++ b/apps/vectorcraft-web/src/locks.rs @@ -35,7 +35,7 @@ const REFRESH_MS: i32 = 10_000; const FRESH_MS: f64 = 60_000.0; /// Whether a snapshot asked for at `asked` can still be trusted at `now`, both in ms on -/// [`vectorcraft_ui_egui::now_ms`]'s clock: it is at most [`FRESH_MS`] old, and not stamped later +/// [`craft_platform::clock::monotonic_ms`]'s clock: it is at most [`FRESH_MS`] old, and not stamped later /// than `now`. fn trusted(asked: f64, now: f64) -> bool { (0.0..=FRESH_MS).contains(&(now - asked)) @@ -54,7 +54,7 @@ thread_local! { pub struct WebLocks { prefix: &'static str, /// The areas whose locks were held at the last snapshot, and when it was asked for (ms on - /// [`vectorcraft_ui_egui::now_ms`]'s monotonic clock, which a change to the system clock does + /// [`craft_platform::clock::monotonic_ms`]'s monotonic clock, which a change to the system clock does /// not move). `navigator.locks.query()` is asynchronous, so the snapshot is refreshed every /// [`REFRESH_MS`] and read from here. seen: Arc)>>, @@ -97,7 +97,7 @@ impl WebLocks { /// Take a new snapshot of the locks held. async fn refresh(&self) -> Option<()> { let m = manager()?; - let asked = vectorcraft_ui_egui::now_ms(); + let asked = craft_platform::clock::monotonic_ms(); let query: Promise = method(&m, "query")?.call0(&m).ok()?.dyn_into().ok()?; let snapshot = wasm_bindgen_futures::JsFuture::from(query).await.ok()?; let held = js_sys::Array::from(&Reflect::get(&snapshot, &"held".into()).ok()?); @@ -113,7 +113,7 @@ impl WebLocks { /// Does a tab hold `area`'s lock? Yes when the last snapshot is too old to tell. pub fn held(&self, area: &str) -> bool { let seen = self.seen.lock().unwrap_or_else(|e| e.into_inner()); - !trusted(seen.0, vectorcraft_ui_egui::now_ms()) || seen.1.contains(area) + !trusted(seen.0, craft_platform::clock::monotonic_ms()) || seen.1.contains(area) } /// Hold `area`'s lock until the returned hold is dropped (or the page goes). diff --git a/crates/ui-egui/src/thumb_worker.rs b/crates/ui-egui/src/thumb_worker.rs index 7a04484dc2..71ea6a4749 100644 --- a/crates/ui-egui/src/thumb_worker.rs +++ b/crates/ui-egui/src/thumb_worker.rs @@ -117,9 +117,9 @@ impl ThumbWorker { if skip { continue; } - let t0 = crate::now_ms(); + let t0 = craft::platform::clock::monotonic_ms(); let img = (job.run)(&mut r); - let done = Done { key: job.key, img, ms: crate::now_ms() - t0 }; + let done = Done { key: job.key, img, ms: craft::platform::clock::monotonic_ms() - t0 }; // Sent under the lock, so a `forget` either drops it here or comes after it // and finds it in the next `poll`. let Ok(f) = gone.lock() else { break };