site/node_modules/async-mutex/lib/SemaphoreInterface.d.ts
2024-10-14 08:09:33 +02:00

20 lines
647 B
TypeScript

interface SemaphoreInterface {
acquire(weight?: number, priority?: number): Promise<[number, SemaphoreInterface.Releaser]>;
runExclusive<T>(callback: SemaphoreInterface.Worker<T>, weight?: number, priority?: number): Promise<T>;
waitForUnlock(weight?: number, priority?: number): Promise<void>;
isLocked(): boolean;
getValue(): number;
setValue(value: number): void;
release(weight?: number): void;
cancel(): void;
}
declare namespace SemaphoreInterface {
interface Releaser {
(): void;
}
interface Worker<T> {
(value: number): Promise<T> | T;
}
}
export default SemaphoreInterface;