Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / createSemaphore

Function: createSemaphore()

createSemaphore(initialCount): Semaphore

Defined in: projects/libraries/streamix/src/lib/primitives/semaphore.ts:44

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. Prefer scheduler-backed or stream-based coordination utilities for most use cases.

Released under the MIT License.