@x5e/gink
Version:
an eventually consistent database
17 lines (16 loc) • 538 B
TypeScript
import { CallBack } from "./typedefs";
export declare class PromiseChainLock {
private queue;
/**
* An async function that waits to acquire the lock, then provides a function to unlock.
* Use like:
* const unlockingFunction = await promiseChainLock.acquireLock();
* try {
* // Do some stuff.
* } finally {
* unlockingFunction();
* }
* @returns a promise that resolves when the lock has been acquired, resolving to a cb to unlock it.
*/
acquireLock(): Promise<CallBack>;
}