The acquire
method acquires an slots only if the slot limit is not reached.
Returns true if the slot limit is not reached otherwise false is returned.
The acquireBlocking
method acquires an slots only if the slot limit is not reached.
If the slot limit is reached, it retries every settings.interval
until settings.time
is reached.
Optional
settings: SemaphoreAquireBlockingSettingsReturns true if the slot limit is not reached otherwise false is returned.
The acquireBlockingOrFail
method acquires an slots only if the slot limit is not reached.
If the slot limit is reached, it retries every settings.interval
until settings.time
is reached.
Throws an error if the slot limit is reached after the given settings.time
.
Optional
settings: SemaphoreAquireBlockingSettingsThe acquireOrFail
method acquires an slots only if the slot limit is not reached.
Throws an error if the slot limit is reached.
The forceReleaseAll
method releases the all slots.
Returns true if the semaphore exists and has at least one unavailable slot or false if all slots are available.
The refresh
method updates the ttl
of the slot when acquired.
Optional
ttl: ITimeSpanReturns true if the slot is refreshed otherwise false is returned.
The refreshOrFail
method updates the ttl
of the slot when acquired.
Throws an error if the slot is not acquired.
Optional
ttl: ITimeSpanThe release
method releases the current slot.
Returns true if the semaphore exists and has at least one busy slot or false.
The releaseOrFail
method releases the current slot.
Throws an error if the slot is not acquired.
The run
method wraps an Invokable | Invokable
or LazyPromise
with the acquire
and release
method.
The runBlocking
method wraps an Invokable | Invokable
or LazyPromise
with the acquireBlocking
and release
method.
Optional
settings: SemaphoreAquireBlockingSettingsThe runBlockingOrFail
method wraps an Invokable | Invokable
or LazyPromise
with the acquireBlockingOrFail
and release
method.
Optional
settings: SemaphoreAquireBlockingSettingsThe runOrFail
method wraps an Invokable | Invokable
or LazyPromise
with the acquireOrFail
and release
method.
IMPORT_PATH:
"@daiso-tech/core/semaphore/contracts"