server/concurrency library

Concurrency primitives used by Database:

  • AsyncRwLock — in-process multi-reader / single-writer lock built on completers. Fair: writers don't starve readers and vice-versa.
  • DbFileLock — best-effort cross-process advisory lock on a sidecar <dbpath>.lock file using RandomAccessFile.lock().

These are deliberately tiny and dependency-free. They aren't meant to stand in for a real WAL — they protect the JSON file from double-writers and serialize executor mutations within a single process.

Classes

AsyncRwLock
Async multi-reader / single-writer lock.
DbFileLock
Best-effort cross-process advisory lock on a JSON database file.