455493dfad
- Added native `FileLock` bindings supporting cross-process advisory locking on Linux, Unix, and Windows. - Replaced directory-based file locking and custom stale-lock reclamation with OS-backed native locks. - Updated TypeScript declarations, native bindings, and package documentation for the new API. - Added comprehensive unit tests and fixtures validating single-owner constraints and process death handoff.
15 lines
401 B
TypeScript
15 lines
401 B
TypeScript
import { withFileLock } from "../../src/file-lock";
|
|
|
|
const target = Bun.argv[2];
|
|
const readyPath = Bun.argv[3];
|
|
if (!target || !readyPath) throw new Error("file-lock-holder requires target and readiness paths");
|
|
|
|
await withFileLock(
|
|
target,
|
|
async () => {
|
|
await Bun.write(readyPath, "ready");
|
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0);
|
|
},
|
|
{ retries: 1, retryDelayMs: 0 },
|
|
);
|