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 | 885da82bb0d169f995598e0ba7c75523b1f98080 (patch) | |
| tree | 6c387f78946d8661a544da2185d92fe751c87761 /src/state/host.rs | |
| parent | 1202c0ba9bf49e7e31492c90b37af3e6c91b98b7 (diff) | |
remake: copy stale view when writes stop
This ensures that stale reads show every write that was answered.
Diffstat (limited to 'src/state/host.rs')
| -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 { |
