(self: TxSemaphore): Effect.Effect<number>Gets the maximum capacity (total permits) of the semaphore.
When to use
Use to inspect the fixed total number of permits managed by the semaphore.
Example (Checking semaphore capacity)
import { Console, Effect, TxSemaphore } from "effect"
const program = Effect.gen(function*() {
const semaphore = yield* TxSemaphore.make(10)
const capacity = yield* TxSemaphore.capacity(semaphore)
yield* Console.log(`Semaphore capacity: ${capacity}`) // 10
// Capacity remains constant regardless of current permits
yield* TxSemaphore.acquire(semaphore)
const stillSame = yield* TxSemaphore.capacity(semaphore)
yield* Console.log(`Capacity after acquire: ${stillSame}`) // 10
})combinatorsavailable
Source effect/TxSemaphore.ts:2021 lines
export const const capacity: (
self: TxSemaphore
) => Effect.Effect<number>
Gets the maximum capacity (total permits) of the semaphore.
When to use
Use to inspect the fixed total number of permits managed by the semaphore.
Example (Checking semaphore capacity)
import { Console, Effect, TxSemaphore } from "effect"
const program = Effect.gen(function*() {
const semaphore = yield* TxSemaphore.make(10)
const capacity = yield* TxSemaphore.capacity(semaphore)
yield* Console.log(`Semaphore capacity: ${capacity}`) // 10
// Capacity remains constant regardless of current permits
yield* TxSemaphore.acquire(semaphore)
const stillSame = yield* TxSemaphore.capacity(semaphore)
yield* Console.log(`Capacity after acquire: ${stillSame}`) // 10
})
capacity = (self: TxSemaphore(parameter) self: {
permitsRef: TxRef.TxRef<number>;
capacity: number;
toString: () => string;
toJSON: () => unknown;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self: TxSemaphore): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<number> => import EffectEffect.succeed(self: TxSemaphore(parameter) self: {
permitsRef: TxRef.TxRef<number>;
capacity: number;
toString: () => string;
toJSON: () => unknown;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self.TxSemaphore.capacity: numbercapacity)