/** * AsyncLock provides a mutual exclusion primitive for asynchronous operations. * Ensures only one async operation can proceed at a time while queuing others. */ export declare class AsyncLock { private locked; private queue; /** * Acquire the lock. If already locked, waits until released. * @returns Promise that resolves when lock is acquired */ acquire(): Promise; /** * Release the lock. If others are waiting, grants lock to next in queue. */ release(): void; /** * Run a function with the lock acquired, automatically releasing after. * This is the recommended way to use AsyncLock to prevent forgetting to release. * * @param fn - Async function to run with lock held * @returns Promise resolving to the function's return value * * @example * ```typescript * const lock = new AsyncLock() * const result = await lock.run(async () => { * // Critical section - only one caller at a time * return await doSomething() * }) * ``` */ run(fn: () => Promise): Promise; /** * Check if lock is currently held */ isLocked(): boolean; /** * Get number of operations waiting for the lock */ getQueueLength(): number; }