@epikodelabs/streamix / Semaphore
Interface: Semaphore
Defined in: projects/libraries/streamix/src/lib/primitives/semaphore.ts:11
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:18
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: () =>
null|ReleaseFn
Defined in: projects/libraries/streamix/src/lib/primitives/semaphore.ts:25
Attempts to acquire a permit from the semaphore without blocking.
Returns
null | ReleaseFn
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:31
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