import * as tsplus_module_1 from "@effect/core/io/FiberRef/operations/currentParallelism";
import * as tsplus_module_2 from "@effect/core/io/FiberRef/operations/get";
import * as tsplus_module_3 from "@effect/core/io/FiberRef/operations/getWith";
import * as tsplus_module_4 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_5 from "@effect/core/io/FiberRef/operations/locally";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/suspendSucceed";
/**
 * Retrieves the maximum number of fibers for parallel operators or `None` if
 * it is unbounded.
 *
 * @tsplus static ets/Effect/Ops parallelism
 */

export function parallelism(__tsplusTrace) {
  return tsplus_module_2.get(tsplus_module_1.currentParallelism.value, __tsplusTrace);
}
/**
 * Retrieves the current maximum number of fibers for parallel operators and
 * uses it to run the specified effect.
 *
 * @tsplus static ets/Effect/Ops parallelismWith
 */

export function parallelismWith(f, __tsplusTrace) {
  return tsplus_module_3.getWith_(tsplus_module_1.currentParallelism.value, f, __tsplusTrace);
}
/**
 * Runs the specified effect with the specified maximum number of fibers for
 * parallel operators.
 *
 * @tsplus fluent ets/Effect withParallelism
 */

export function withParallelism_(self, n, __tsplusTrace) {
  return tsplus_module_6.suspendSucceed(() => tsplus_module_5.locally_(tsplus_module_1.currentParallelism.value, tsplus_module_4.some(n), __tsplusTrace)(self), __tsplusTrace);
}
/**
 * Runs the specified effect with the specified maximum number of fibers for
 * parallel operators.
 *
 * @tsplus static ets/Effect/Aspects withParallelism
 */

export const withParallelism = (n, __tsplusTrace) => self => withParallelism_(self, n, __tsplusTrace);
/**
 * Runs the specified effect with an unbounded maximum number of fibers for
 * parallel operators.
 *
 * @tsplus fluent ets/Effect withParallelismUnbounded
 */

export function withParallelismUnbounded(self, __tsplusTrace) {
  return tsplus_module_6.suspendSucceed(() => tsplus_module_5.locally_(tsplus_module_1.currentParallelism.value, tsplus_module_4.none, __tsplusTrace)(self), __tsplusTrace);
}
//# sourceMappingURL=parallelism.mjs.map