Context.Reference<number | "unbounded">Context reference for controlling the current concurrency limit. Can be set to "unbounded" for unlimited concurrency or a specific number to limit concurrent operations.
When to use
Use to configure the default concurrency limit for operations that read concurrency from the current context.
Example (Setting current concurrency)
import { Effect, References } from "effect"
const limitConcurrency = Effect.gen(function*() {
// Get current setting
const current = yield* References.CurrentConcurrency
console.log(current) // "unbounded" (default)
// Run with limited concurrency
yield* Effect.provideService(
Effect.gen(function*() {
const limited = yield* References.CurrentConcurrency
console.log(limited) // 10
}),
References.CurrentConcurrency,
10
)
// Run with unlimited concurrency
yield* Effect.provideService(
Effect.gen(function*() {
const unlimited = yield* References.CurrentConcurrency
console.log(unlimited) // "unbounded"
}),
References.CurrentConcurrency,
"unbounded"
)
})references
Source effect/References.ts:1711 lines
export const const CurrentConcurrency: Context.Reference<
number | "unbounded"
>
const CurrentConcurrency: {
defaultValue: () => Shape;
of: (this: void, self: number | 'unbounded') => number | 'unbounded';
context: (self: number | 'unbounded') => Context.Context<never>;
use: (f: (service: number | 'unbounded') => Effect<A, E, R>) => Effect<A, E, R>;
useSync: (f: (service: number | 'unbounded') => A) => Effect<A, never, never>;
Identifier: Identifier;
Service: Shape;
key: string;
stack: string | undefined;
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;
}
Context reference for controlling the current concurrency limit. Can be set to "unbounded"
for unlimited concurrency or a specific number to limit concurrent operations.
When to use
Use to configure the default concurrency limit for operations that read
concurrency from the current context.
Example (Setting current concurrency)
import { Effect, References } from "effect"
const limitConcurrency = Effect.gen(function*() {
// Get current setting
const current = yield* References.CurrentConcurrency
console.log(current) // "unbounded" (default)
// Run with limited concurrency
yield* Effect.provideService(
Effect.gen(function*() {
const limited = yield* References.CurrentConcurrency
console.log(limited) // 10
}),
References.CurrentConcurrency,
10
)
// Run with unlimited concurrency
yield* Effect.provideService(
Effect.gen(function*() {
const unlimited = yield* References.CurrentConcurrency
console.log(unlimited) // "unbounded"
}),
References.CurrentConcurrency,
"unbounded"
)
})
CurrentConcurrency: import ContextContext.type Context.Reference = /*unresolved*/ anyReference<number | "unbounded"> = import referencesreferences.const CurrentConcurrency: Context.Reference<
number | "unbounded"
>
const CurrentConcurrency: {
defaultValue: () => Shape;
of: (this: void, self: number | 'unbounded') => number | 'unbounded';
context: (self: number | 'unbounded') => Context.Context<never>;
use: (f: (service: number | 'unbounded') => Effect<A, E, R>) => Effect<A, E, R>;
useSync: (f: (service: number | 'unbounded') => A) => Effect<A, never, never>;
Identifier: Identifier;
Service: Shape;
key: string;
stack: string | undefined;
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;
}
CurrentConcurrency