import { type Logger } from "webappwiz/log"; import type { Fs } from "../fs/fs.js"; import type { Ps } from "../ps/ps.js"; import type { Lock } from "./lock.js"; export interface FileLockOptions { /** How long a holder on another host may hold the lock before it can be stolen. */ stalenessMs?: number; /** * Judge a holder by its pid alone, whatever hostname it was written under, * for hosts whose hostname changes (macOS flips it with the network). */ pidOnly?: boolean; /** How often to re-check a lock that is already taken. */ pollMs?: number; fs?: Fs; ps?: Ps; log?: Logger; } /** * A mutex between processes, held by a directory on disk. A holder that died * is detected and its lock stolen, and the directory is removed on signals and * uncaught exceptions. */ export declare class FileLock implements Lock { readonly path: string; private held; /** The process listeners that remove the lock, while it is held. */ private listeners; private readonly stalenessMs; private readonly pollMs; private readonly pidOnly; private readonly fs; private readonly ps; private readonly log; constructor(path: string, opts?: FileLockOptions); acquire(): Promise; release(): Promise; releaseIfOurs(): Promise; private get holderPath(); private holder; private isStale; private sameHost; private steal; /** * A crashed holder that never releases wedges every other waiter, so the * removal has to survive signals and uncaught exceptions. It is sync * because exit handlers cannot await. */ private registerCleanup; }