rsxjs
Version:
Resilience Extensions for JS.
19 lines (18 loc) • 703 B
TypeScript
/**
* @file src/semaphore/index.ts
* @copyright 2018-present Karim Alibhai. All rights reserved.
*/
import { SemaphoreOptions } from './types';
import { Lock, ReleaseLock } from '../types';
export declare class Semaphore extends Lock {
readonly size: number;
private readonly mutex;
private readonly state;
constructor(options: SemaphoreOptions);
/**
* Tries to obtain a token from the semaphore.
* @param {boolean = true} failWithoutLock if true, it will throw an error if it cannot obtain a token
* @returns {Promise<ReleaseLock>} resolves with a function that can be used to release the token
*/
lock(failWithoutLock?: boolean): Promise<ReleaseLock>;
}