/** * A lock for synchronizing async operations. * Use this to protect a critical section * from getting modified by multiple async operations * at the same time. */ export declare class Mutex { /** * When multiple operations attempt to acquire the lock, * this queue remembers the order of operations. */ private _queue; private _isLocked; /** * Wait until the lock is acquired. * @returns A function that releases the acquired lock. */ acquire(): Promise; /** * Enqueue a function to be run serially. * * This ensures no other functions will start running * until `callback` finishes running. * @param callback Function to be run exclusively. * @returns The return value of `callback`. */ runExclusive(callback: () => Promise): Promise; /** * Check the availability of the resource * and provide access to the next operation in the queue. * * _dispatch is called whenever availability changes, * such as after lock acquire request or lock release. */ private _dispatch; /** * Build a release function for each operation * so that it can release the lock after * the operation is complete. */ private _buildRelease; } type ReleaseFunction = () => void; export {}; //# sourceMappingURL=Mutex.d.ts.map