/** * Retrieves the maximum number of fibers for parallel operators or `None` if * it is unbounded. * * @tsplus static effect/core/io/Effect.Ops parallelism */ export function parallelism(): Effect> { return FiberRef.currentParallelism.get } /** * Retrieves the current maximum number of fibers for parallel operators and * uses it to run the specified effect. * * @tsplus static effect/core/io/Effect.Ops parallelismWith */ export function parallelismWith( f: (parallelism: Maybe) => Effect ): Effect { return FiberRef.currentParallelism.getWith(f) } /** * Runs the specified effect with the specified maximum number of fibers for * parallel operators. * * @tsplus static effect/core/io/Effect.Aspects withParallelism * @tsplus pipeable effect/core/io/Effect withParallelism */ export function withParallelism(n: number) { return (self: Effect): Effect => Effect.suspendSucceed( self.apply(FiberRef.currentParallelism.locally(Maybe.some(n))) ) } /** * Runs the specified effect with an unbounded maximum number of fibers for * parallel operators. * * @tsplus getter effect/core/io/Effect withParallelismUnbounded */ export function withParallelismUnbounded(self: Effect) { return Effect.suspendSucceed( self.apply(FiberRef.currentParallelism.locally(Maybe.none)) ) }