Hyperlinkv0.8.0-beta.28

PartitionedSemaphore

PartitionedSemaphore.makeconsteffect/PartitionedSemaphore.ts:325
<K = unknown>(options: { readonly permits: number }): Effect.Effect<
  PartitionedSemaphore<K>
>

Creates a PartitionedSemaphore inside an Effect.

When to use

Use when semaphore construction should stay inside an Effect workflow.

Details

The permits option sets the shared permit capacity. The resulting semaphore tracks waiters by partition key and distributes released permits across waiting partitions in round-robin order.

Gotchas

Negative permit counts are clamped to 0. Non-finite permit counts create an unbounded semaphore.

constructorsmakeUnsafe
export const make = <K = unknown>(options: {
  readonly permits: number
}): Effect.Effect<PartitionedSemaphore<K>> => Effect.sync(() => makeUnsafe<K>(options))