Creates a new semaphore with the given initial number of permits and maximum number of permits.
The maximum number of permits.
OptionalinitialValue: numberThe initial number of permits available. Defaults to maxValue.
Acquires a permit from the semaphore, waiting if necessary until one is available.
Optionalsignal: AbortSignal | nullAn optional AbortSignal to cancel the acquire operation.
A promise that resolves to a function that releases the acquired permit.
The maximum number of permits.
Releases a permit, returning it to the semaphore.
Tries to acquire a permit from the semaphore immediately, without waiting.
The number of permits to acquire.
true if the permits were acquired, false otherwise.
A counting semaphore implementation.
A semaphore maintains a set of permits. Each
acquirecall blocks if necessary until a permit is available, and then takes it. Eachreleasecall adds a permit, potentially releasing a blocking acquirer.The semaphore is initialized with a given number of permits. The number of permits can be increased up to a maximum value.