Package: effect
Module: TxSemaphore
Gets the current number of available permits in the semaphore.
When to use
Use to inspect how many permits are currently available.
Example (Checking available permits)
import { Console, Effect, TxSemaphore } from "effect"
const program = Effect.gen(function*() {
const semaphore = yield* TxSemaphore.make(5)
// Check available permits before acquiring
const before = yield* TxSemaphore.available(semaphore)
yield* Console.log(`Available permits: ${before}`) // 5
// Acquire some permits
yield* TxSemaphore.acquire(semaphore)
yield* TxSemaphore.acquire(semaphore)
// Check available permits after acquiring
const after = yield* TxSemaphore.available(semaphore)
yield* Console.log(`Available permits: ${after}`) // 3
})
See
capacity for reading the fixed total permit countSignature
declare const available: (self: TxSemaphore) => Effect.Effect<number>
Since v2.0.0