Hermes Wiki

Locks Mutexes ReadWriteLock

Mutexes prevent two threads from touching the same data at once; read-write locks relax that by allowing many concurrent readers but only one writer.

Why we need this / what value this brings

Without a lock, two threads writing the same shared state can interleave in ways that corrupt it — locks make the operation atomic from other threads' perspective.

When to use this

Any time multiple threads/tasks touch the same mutable shared state — not needed for state confined to one request/task.

How to use or implement this

Prefer a read-write lock over a plain mutex whenever reads vastly outnumber writes, since it lets reads proceed concurrently while still serializing writes.

Research questions

  • Where would a read-write lock outperform a plain mutex — data that's read far more often than it's written?

Empty folder — drop notes, links, and findings here as you research.

Hermes Wiki