Granary_store.RwlockSourceWriter-mutex + reader-counter for Lwt.
Semantics (intentionally NOT a classic shared/exclusive RwLock):
Rationale: under snapshot isolation (see Store.ro_snapshot and Pager.read ~snapshot_frames) a reader's view at WAL frame N is invariant under a concurrent writer's appends, so reader/writer mutual exclusion is not needed for correctness. This module only serialises writers and tracks active readers for the checkpoint coordinator.
Re-entrancy is NOT supported — a fiber that holds the writer lock must not call acquire_write again.
acquire_read increments the reader counter and returns immediately. Never blocks.
release_read decrements the counter; broadcasts when it reaches zero (used by the checkpoint coordinator).
acquire_write blocks while another writer is active. Does NOT block on active readers.
Acquire shared (reader) access for the duration of f.
Acquire exclusive (writer) access for the duration of f.
True iff a writer is currently holding (or queued for) the lock. Diagnostic only — not used by Store for any control flow now that readers and writers don't mutually exclude.