/** * KeyedMutex — per-key async serialization primitive. * * Concurrent calls with DIFFERENT keys run in parallel. * Concurrent calls with the SAME key are queued and run strictly FIFO. * * NON-REENTRANT by design: calling withKeyLock(k, ...) from *inside* a fn * that is already holding lock k will deadlock. Callers must not nest * same-key locks. If you need reentrance, restructure the call to pass the * already-computed value in or extract the critical section into a helper * that runs outside the lock. * * Memory: once a key has no holder and no waiters its internal entry is * deleted — the Map does not grow unboundedly. */ export declare class KeyedMutex { private readonly locks; /** * Acquire the lock for `key`, execute `fn`, release the lock, and return * the resolved value of `fn`. If `fn` throws or rejects, the error is * propagated to the caller and the lock is released so the next waiter * can proceed. */ withKeyLock(key: string, fn: () => Promise | T): Promise; /** * Number of keys that currently have an active holder or at least one * waiter. Returns 0 once all locks have fully drained. * Exposed for testing; not part of the production surface. */ size(): number; /** * Whether an entry exists for `key` (holder or waiters present). * Exposed for testing; not part of the production surface. */ hasKey(key: string): boolean; } //# sourceMappingURL=keyed-mutex.d.ts.map