@epikodelabs/streamix / Semaphore
Interface: Semaphore
Defined in: projects/libraries/streamix/src/lib/primitives/semaphore.ts:10
An interface for a semaphore, a synchronization primitive for controlling access to a limited number of resources.
Prefer scheduler-backed or stream-based coordination utilities for most use cases.
Properties
acquire()
acquire: () =>
Promise<ReleaseFn>
Defined in: projects/libraries/streamix/src/lib/primitives/semaphore.ts:17
Acquires a permit from the semaphore. If no permits are available, this promise-based method will block until a permit is released.
Returns
Promise<ReleaseFn>
A promise that resolves with a function to call to release the permit.
tryAcquire()
tryAcquire: () =>
ReleaseFn|null
Defined in: projects/libraries/streamix/src/lib/primitives/semaphore.ts:24
Attempts to acquire a permit from the semaphore without blocking.
Returns
ReleaseFn | null
A function to call to release the permit if one was acquired, otherwise null.
release()
release: () =>
void
Defined in: projects/libraries/streamix/src/lib/primitives/semaphore.ts:30
Releases a permit back to the semaphore. This unblocks the next waiting acquire call in the queue or increments the available permit count.
Returns
void