<K>(key: K, permits: number): (
self: PartitionedSemaphore<K>
) => Effect.Effect<void>
<K>(
self: PartitionedSemaphore<K>,
key: K,
permits: number
): Effect.Effect<void>Returns an effect that acquires the requested number of permits for the given partition key.
When to use
Use when you need manual permit acquisition for a partition and want to control acquisition and release as separate effects.
Details
If enough permits are available, the effect completes immediately. Otherwise it waits until released permits are assigned to this partition.
Gotchas
Requests for more permits than the semaphore capacity never complete. Requests for zero or a negative number of permits complete without acquiring anything.
export const const take: {
<K>(key: K, permits: number): (
self: PartitionedSemaphore<K>
) => Effect.Effect<void>
<K>(
self: PartitionedSemaphore<K>,
key: K,
permits: number
): Effect.Effect<void>
}
Returns an effect that acquires the requested number of permits for the
given partition key.
When to use
Use when you need manual permit acquisition for a partition and want to
control acquisition and release as separate effects.
Details
If enough permits are available, the effect completes immediately. Otherwise
it waits until released permits are assigned to this partition.
Gotchas
Requests for more permits than the semaphore capacity never complete.
Requests for zero or a negative number of permits complete without acquiring
anything.
take: {
<function (type parameter) K in <K>(key: K, permits: number): (self: PartitionedSemaphore<K>) => Effect.Effect<void>K>(key: Kkey: function (type parameter) K in <K>(key: K, permits: number): (self: PartitionedSemaphore<K>) => Effect.Effect<void>K, permits: numberpermits: 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: 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>(key: K, permits: number): (self: PartitionedSemaphore<K>) => Effect.Effect<void>K>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void>
<function (type parameter) K in <K>(self: PartitionedSemaphore<K>, key: K, permits: number): Effect.Effect<void>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>, key: K, permits: number): Effect.Effect<void>K>, key: Kkey: function (type parameter) K in <K>(self: PartitionedSemaphore<K>, key: K, permits: number): Effect.Effect<void>K, permits: numberpermits: number): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void>
} = import dualdual(3, <function (type parameter) K in <K>(self: PartitionedSemaphore<K>, key: K, permits: number): Effect.Effect<void>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>, key: K, permits: number): Effect.Effect<void>K>, key: Kkey: function (type parameter) K in <K>(self: PartitionedSemaphore<K>, key: K, permits: number): Effect.Effect<void>K, permits: numberpermits: number): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void> => 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<K>.take: (key: K, permits: number) => Effect.Effect<void>take(key: Kkey, permits: numberpermits))