Skip to main content

Module locks

Module locks 

Source
Expand description

Resource lock registry with full lifecycle.

Provides acquire/release/heartbeat/TTL-expire/startup-cleanup for any scoped resource operation, wired to the typed event system from task 9.

§OCP contract

  • Adding a new scope dimension: add one optional field to LockScope and one intersection arm in LockScope::intersects. No existing arms change.
  • Adding a new release reason: add one ReleaseReason variant. Serializes automatically via rename_all = "snake_case".
  • Heartbeat loop works for any scope — it is a generic background task that calls release_stale on any LockRegistry.
  • Event emission uses events::emit — no string literals scattered at call sites.

Modules§

lifecycle
Background lifecycle tasks for the lock registry.

Structs§

LockAcquiredPayload
LockId
Opaque lock identifier — UUID v4 minted on acquire.
LockRegistry
Thread-safe in-memory registry of active resource locks.
LockRegistryHandle
Arc<LockRegistry> wrapped for Tauri’s State system.
LockReleasedPayload
LockScope
Hierarchical scope key for a resource lock.
RegistryInner 🔒
Inner registry state — separated so tests can poke at it directly.
ResourceLock
An active resource lock held by an operation.

Enums§

ReleaseReason
Why a lock was released.

Functions§

emit_acquired
Emit lock:acquired for lock.
emit_released
Emit lock:released for a lock that was removed with reason.