Skip to content

Function: createSemaphore()

createSemaphore(initialCount): Semaphore

Defined in: primitives/semaphore.ts:41

Creates a semaphore for controlling access to a limited number of resources.

A semaphore is a synchronization primitive that allows you to manage concurrent access to resources by maintaining a count of available "permits."

Parameters

initialCount

number

The initial number of permits available. Must be a non-negative integer.

Returns

Semaphore

A semaphore object with acquire, tryAcquire, and release methods.

Released under the MIT License.