igir
Version:
🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
19 lines (18 loc) • 605 B
TypeScript
/**
* Wrapper for `async-mutex` {@link Mutex}es to run code exclusively for a key.
*/
export default class KeyedMutex {
private readonly keyMutexes;
private readonly keyMutexesMutex;
private keyMutexesLru;
private readonly maxSize?;
constructor(maxSize?: number);
/**
* Run a {@link runnable} exclusively across all keys.
*/
runExclusiveGlobally<V>(runnable: () => V | Promise<V>): Promise<V>;
/**
* Run a {@link runnable} exclusively for the given {@link key}.
*/
runExclusiveForKey<V>(key: string, runnable: () => V | Promise<V>): Promise<V>;
}