Skip to main content

Module lock

Module lock 

Source
Expand description

The computer-wide sync lock (SPEC_USER_DATA_SYNC_LAYER §3.1). The identity store, and with it the Kanban and the Vaults, is shared by every AgentMux on a computer, so only one install may act as the computer’s member: sign records as it, run the sync loop and answer sync.* ops. That install holds this lock, a single row in the shared store taken by compare-and-set with a lease. An install that does not hold it never signs as the member and never runs the loop; a crashed holder is replaced when its lease runs out. Each taking raises a generation, so a holder that was replaced finds its renewal refused and stops (a fence, like a task claim’s attempt).

Enums§

Lock
The answer to a request for the lock.

Constants§

LEASE_MS
How long a lease lasts before a crashed holder can be replaced.

Functions§

acquire
Takes the lock for install if it is free, expired or already its own. One statement decides, so two installs asking at once cannot both get it.
holds
Whether install holds the lock at generation right now: the check made before signing as the member.
init
release
Gives the lock up (an install shutting down), if it holds it.
renew
Extends the lease if install still holds the lock at generation; false means it was replaced and must stop.