Hyperlinkv0.8.0-beta.28

PartitionedSemaphore

PartitionedSemaphore.releaseconsteffect/PartitionedSemaphore.ts:428
(permits: number): <K>(
  self: PartitionedSemaphore<K>
) => Effect.Effect<number>
<K>(self: PartitionedSemaphore<K>, permits: number): Effect.Effect<number>

Returns an effect that releases permits back to the shared pool and returns the current available permit count.

When to use

Use when you need to return permits acquired with take in a lower-level partitioned permit protocol with explicit release control.

Details

Released permits are first assigned to waiting partitions in round-robin order. Only permits not needed by waiters increase the available count, which is capped at the semaphore capacity.

export const release: {
  (permits: number): <K>(self: PartitionedSemaphore<K>) => Effect.Effect<number>
  <K>(self: PartitionedSemaphore<K>, permits: number): Effect.Effect<number>
} = dual(2, <K>(self: PartitionedSemaphore<K>, permits: number): Effect.Effect<number> => self.release(permits))