SuperPi.Env.FileLock (super_pi v0.1.0)

Copy Markdown View Source

Per-path advisory file lock server (REQ-SAFE-04, REQ-PBT-05).

Registered in SuperPi.Registry under {:file_lock, env_id, canonical_path} so concurrent write_file and edit_file operations targeting the same path execute strictly sequentially without lost updates or race conditions.

Summary

Functions

Returns a specification to start this module under a supervisor.

Executes fun.() inside the exclusive lock for {env_id, path}. Resolves Path.expand/1 before acquiring the lock so relative and absolute paths to the same file share the same lock process.

Functions

canonicalize_path(path)

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(arg)

with_lock(env_id, path, fun)

Executes fun.() inside the exclusive lock for {env_id, path}. Resolves Path.expand/1 before acquiring the lock so relative and absolute paths to the same file share the same lock process.

with_lock(env_id, path, timeout, fun)