diff options
| author | tv <tv@krebsco.de> | 2026-11-01 13:37:04 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-01 13:37:04 +0100 |
| commit | 5f2fdae1ea54b73eeb2352a28c6558b1e344e4e2 (patch) | |
| tree | 605dc197f553df4572e3b1f1a5992bc8184d2507 /src/state | |
| parent | efbc9899ab92c34db607f26c0e1b676e1e9d1c81 (diff) | |
remake: copy stale view when writes stop
This ensures that stale reads show every write that was answered.
Diffstat (limited to 'src/state')
| -rw-r--r-- | src/state/host.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/state/host.rs b/src/state/host.rs index 7c3e165..30ebcdb 100644 --- a/src/state/host.rs +++ b/src/state/host.rs @@ -226,6 +226,19 @@ impl Host for AppState { async move { state.mutate_doc(f).await } } + fn refuse_writes(&self, copy: bool) -> impl Future<Output = Option<Document>> + Send { + let state = self.clone(); + async move { + tokio::task::spawn_blocking(move || { + let mut replica = state.doc.blocking_write(); + replica.writable = false; + copy.then(|| replica.doc.clone()) + }) + .await + .expect("document write task panicked") + } + } + fn accept_writes(&self) -> impl Future<Output = ()> + Send { let state = self.clone(); async move { |
