<K>(self: PartitionedSemaphore<K>): Effect.Effect<number>Gets the current number of available permits.
When to use
Use to inspect a snapshot of how many permits are currently free.
Details
Running the returned effect reads the semaphore's current availability. Taking permits decreases availability, and releasing permits can increase it up to the semaphore capacity.
Gotchas
Reading availability does not reserve permits.
export const const available: <K>(
self: PartitionedSemaphore<K>
) => Effect.Effect<number>
Gets the current number of available permits.
When to use
Use to inspect a snapshot of how many permits are currently free.
Details
Running the returned effect reads the semaphore's current availability.
Taking permits decreases availability, and releasing permits can increase it
up to the semaphore capacity.
Gotchas
Reading availability does not reserve permits.
available = <function (type parameter) K in <K>(self: PartitionedSemaphore<K>): Effect.Effect<number>K>(self: PartitionedSemaphore<K>(parameter) self: {
capacity: number;
available: Effect.Effect<number>;
take: (key: K, permits: number) => Effect.Effect<void>;
release: (permits: number) => Effect.Effect<number>;
withPermits: (key: K, permits: number) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
withPermit: (key: K) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
withPermitsIfAvailable: (permits: number) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>;
}
self: interface PartitionedSemaphore<in K>A PartitionedSemaphore controls access to a shared permit pool while
tracking waiters by partition key.
When to use
Use to coordinate shared permits across partition keys so waiting groups make
progress without one group monopolizing the pool.
Details
Waiting permits are distributed across partitions in round-robin order.
PartitionedSemaphore<function (type parameter) K in <K>(self: PartitionedSemaphore<K>): Effect.Effect<number>K>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<number> => self: PartitionedSemaphore<K>(parameter) self: {
capacity: number;
available: Effect.Effect<number>;
take: (key: K, permits: number) => Effect.Effect<void>;
release: (permits: number) => Effect.Effect<number>;
withPermits: (key: K, permits: number) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
withPermit: (key: K) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
withPermitsIfAvailable: (permits: number) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>;
}
self.PartitionedSemaphore<in K>.available: Effect.Effect<number>(property) PartitionedSemaphore<in K>.available: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
available