/** * @since 4.0.0 */ import * as Effect from "./Effect.ts"; import * as Option from "./Option.ts"; /** * @since 4.0.0 * @category models */ export declare const PartitionedTypeId: PartitionedTypeId; /** * @since 4.0.0 * @category models */ export type PartitionedTypeId = "~effect/PartitionedSemaphore"; /** * A `PartitionedSemaphore` controls access to a shared permit pool while * tracking waiters by partition key. * * Waiting permits are distributed across partitions in round-robin order. * * @since 4.0.0 * @category models */ export interface PartitionedSemaphore { readonly [PartitionedTypeId]: PartitionedTypeId; readonly capacity: number; readonly available: Effect.Effect; readonly take: (key: K, permits: number) => Effect.Effect; readonly release: (permits: number) => Effect.Effect; readonly withPermits: (key: K, permits: number) => (effect: Effect.Effect) => Effect.Effect; readonly withPermit: (key: K) => (effect: Effect.Effect) => Effect.Effect; readonly withPermitsIfAvailable: (permits: number) => (effect: Effect.Effect) => Effect.Effect, E, R>; } /** * @since 4.0.0 * @category models */ export interface Partitioned extends PartitionedSemaphore { } /** * Creates a `PartitionedSemaphore` unsafely. * * @since 4.0.0 * @category constructors */ export declare const makeUnsafe: (options: { readonly permits: number; }) => PartitionedSemaphore; /** * Creates a `PartitionedSemaphore`. * * @since 4.0.0 * @category constructors */ export declare const make: (options: { readonly permits: number; }) => Effect.Effect>; /** * Gets the current number of available permits. * * @since 4.0.0 * @category combinators */ export declare const available: (self: PartitionedSemaphore) => Effect.Effect; /** * Gets the total capacity. * * @since 4.0.0 * @category getters */ export declare const capacity: (self: PartitionedSemaphore) => number; /** * Acquires permits for a partition. * * @since 4.0.0 * @category combinators */ export declare const take: { /** * Acquires permits for a partition. * * @since 4.0.0 * @category combinators */ (key: K, permits: number): (self: PartitionedSemaphore) => Effect.Effect; /** * Acquires permits for a partition. * * @since 4.0.0 * @category combinators */ (self: PartitionedSemaphore, key: K, permits: number): Effect.Effect; }; /** * Releases permits back to the shared pool. * * @since 4.0.0 * @category combinators */ export declare const release: { /** * Releases permits back to the shared pool. * * @since 4.0.0 * @category combinators */ (permits: number): (self: PartitionedSemaphore) => Effect.Effect; /** * Releases permits back to the shared pool. * * @since 4.0.0 * @category combinators */ (self: PartitionedSemaphore, permits: number): Effect.Effect; }; /** * Runs an effect with permits for a partition. * * @since 4.0.0 * @category combinators */ export declare const withPermits: { /** * Runs an effect with permits for a partition. * * @since 4.0.0 * @category combinators */ (self: PartitionedSemaphore, key: K, permits: number): (effect: Effect.Effect) => Effect.Effect; /** * Runs an effect with permits for a partition. * * @since 4.0.0 * @category combinators */ (self: PartitionedSemaphore, key: K, permits: number, effect: Effect.Effect): Effect.Effect; }; /** * Runs an effect with a single permit for a partition. * * @since 4.0.0 * @category combinators */ export declare const withPermit: { /** * Runs an effect with a single permit for a partition. * * @since 4.0.0 * @category combinators */ (self: PartitionedSemaphore, key: K): (effect: Effect.Effect) => Effect.Effect; /** * Runs an effect with a single permit for a partition. * * @since 4.0.0 * @category combinators */ (self: PartitionedSemaphore, key: K, effect: Effect.Effect): Effect.Effect; }; /** * Runs an effect only if the permits are immediately available. * * @since 4.0.0 * @category combinators */ export declare const withPermitsIfAvailable: { /** * Runs an effect only if the permits are immediately available. * * @since 4.0.0 * @category combinators */ (self: PartitionedSemaphore, permits: number): (effect: Effect.Effect) => Effect.Effect, E, R>; /** * Runs an effect only if the permits are immediately available. * * @since 4.0.0 * @category combinators */ (self: PartitionedSemaphore, permits: number, effect: Effect.Effect): Effect.Effect, E, R>; }; //# sourceMappingURL=PartitionedSemaphore.d.ts.map