Skip to content

PartitionedSemaphore

5 exports Added in v3.19.4 Source

Constructors

make

Added in v3.19.4 Source

A PartitionedSemaphore is a concurrency primitive that can be used to control concurrent access to a resource across multiple partitions identified by keys.

The total number of permits is shared across all partitions, with waiting permits equally distributed among partitions using a round-robin strategy.

This is useful when you want to limit the total number of concurrent accesses to a resource, while still allowing for fair distribution of access across different partitions.

Signature

declare function make<K = unknown>(options: {
  readonly permits: number;
}): Effect<PartitionedSemaphore<K>>;

makeUnsafe

Added in v3.19.4 Source

A PartitionedSemaphore is a concurrency primitive that can be used to control concurrent access to a resource across multiple partitions identified by keys.

The total number of permits is shared across all partitions, with waiting permits equally distributed among partitions using a round-robin strategy.

This is useful when you want to limit the total number of concurrent accesses to a resource, while still allowing for fair distribution of access across different partitions.

Signature

declare function makeUnsafe<K = unknown>(options: {
  readonly permits: number;
}): PartitionedSemaphore<K>;

Models

PartitionedSemaphore interface

Added in v3.19.4 Source

A PartitionedSemaphore is a concurrency primitive that can be used to control concurrent access to a resource across multiple partitions identified by keys.

The total number of permits is shared across all partitions, with waiting permits equally distributed among partitions using a round-robin strategy.

This is useful when you want to limit the total number of concurrent accesses to a resource, while still allowing for fair distribution of access across different partitions.

Signature

interface PartitionedSemaphore<in K> {
  readonly "~effect/PartitionedSemaphore": "~effect/PartitionedSemaphore";
  readonly withPermits: (
    key: K,
    permits: number,
  ) => <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>;
}

TypeId

Added in v3.19.4 Source

Signature

declare const TypeId: TypeId;

TypeId type

Added in v3.19.4 Source

Signature

type TypeId = "~effect/PartitionedSemaphore";