@ac-essentials/misc-util
    Preparing search index...

    Class FileLock

    A simple file-based lock mechanism.

    Creates a .lock file to indicate that a resource is locked. The lock is acquired by creating the lock file and released by deleting it. If the lock file already exists, it means the resource is locked by another process.

    Example usage:

    const lock = new LockFile("/path/to/resource");
    const release = await lock.acquire();
    try {
    // Do something with the locked resource
    } finally {
    await release();
    }

    Implements

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    filePath: string

    Accessors

    Methods

    • Acquires the lock, waiting if necessary until it is available.

      Parameters

      • Optionalsignal: AbortSignal | null

        An optional AbortSignal to cancel the acquire operation.

      Returns Promise<void>

      A promise that resolves when the lock is acquired.