/** * One runner per run: `lock.json` in the run directory, made exclusively at * the start and at each resume, holding the pid and the host of the process * running it, and removed in a `finally`. * * Only a process on this host can be asked whether it is alive. A lock held * by a live one refuses with its pid; one whose process is gone was left by a * run that died, and is taken over. A lock from another host cannot be * judged from here, so it refuses with its path, to be removed by hand. * * Two takers can both find the same lock stale. A takeover is therefore made * holding `lock.json.takeover`, made exclusively too, which lets one taker * through at a time: it reads the lock again, and replaces it in one rename, * so the lock is never missing for another taker's exclusive make. */ /** Where the lock is, in a run directory. */ export declare const LOCK_FILE = "lock.json"; /** What a lock holds. */ export type Held = { /** The process running the run. */ readonly pid: number; /** The host that process runs on, the only one that can ask it whether it lives. */ readonly host: string; }; /** A lock taken: `release` removes it, once. */ export type Lock = { release(): void; }; /** * Takes the lock of `runDir`, or says why it is not ours to take. `read` is * how a lock is read, a seam for a test to interleave another taker. */ export declare function takeLock(runDir: string, read?: (file: string) => Held | undefined): Lock | string; /** * Runs `run` holding the lock of `runDir`, released however it ends; or * hands `refused` why the lock is not ours. */ export declare function whileLocked(runDir: string, refused: (why: string) => T, run: () => Promise): Promise; /** What the lock at `file` holds, when it can be read. */ export declare function heldBy(file: string): Held | undefined; //# sourceMappingURL=lock.d.ts.map