import * as Deferred from "./Deferred.js"; import * as Effect from "./Effect.js"; import * as Fiber from "./Fiber.js"; import * as FiberId from "./FiberId.js"; import * as Inspectable from "./Inspectable.js"; import { type Pipeable } from "./Pipeable.js"; import * as Runtime from "./Runtime.js"; import type * as Scope from "./Scope.js"; /** * @since 2.0.0 * @categories type ids */ export declare const TypeId: unique symbol; /** * @since 2.0.0 * @categories type ids */ export type TypeId = typeof TypeId; /** * @since 2.0.0 * @categories models */ export interface FiberSet extends Pipeable, Inspectable.Inspectable, Iterable> { readonly [TypeId]: TypeId; readonly deferred: Deferred.Deferred; } /** * @since 2.0.0 * @categories refinements */ export declare const isFiberSet: (u: unknown) => u is FiberSet; /** * A FiberSet can be used to store a collection of fibers. * When the associated Scope is closed, all fibers in the set will be interrupted. * * You can add fibers to the set using `FiberSet.add` or `FiberSet.run`, and the fibers will * be automatically removed from the FiberSet when they complete. * * @example * ```ts * import { Effect, FiberSet } from "effect" * * Effect.gen(function*() { * const set = yield* FiberSet.make() * * // run some effects and add the fibers to the set * yield* FiberSet.run(set, Effect.never) * yield* FiberSet.run(set, Effect.never) * * yield* Effect.sleep(1000) * }).pipe( * Effect.scoped // The fibers will be interrupted when the scope is closed * ) * ``` * * @since 2.0.0 * @categories constructors */ export declare const make: () => Effect.Effect, never, Scope.Scope>; /** * Create an Effect run function that is backed by a FiberSet. * * @since 2.0.0 * @categories constructors */ export declare const makeRuntime: () => Effect.Effect<((effect: Effect.Effect, options?: Runtime.RunForkOptions | undefined) => Fiber.RuntimeFiber), never, Scope.Scope | R>; /** * Create an Effect run function that is backed by a FiberSet. * * @since 3.13.0 * @categories constructors */ export declare const makeRuntimePromise: () => Effect.Effect<((effect: Effect.Effect, options?: Runtime.RunForkOptions | undefined) => Promise), never, Scope.Scope | R>; /** * Add a fiber to the FiberSet. When the fiber completes, it will be removed. * * @since 2.0.0 * @categories combinators */ export declare const unsafeAdd: { /** * Add a fiber to the FiberSet. When the fiber completes, it will be removed. * * @since 2.0.0 * @categories combinators */ (fiber: Fiber.RuntimeFiber, options?: { readonly interruptAs?: FiberId.FiberId | undefined; readonly propagateInterruption?: boolean | undefined; } | undefined): (self: FiberSet) => void; /** * Add a fiber to the FiberSet. When the fiber completes, it will be removed. * * @since 2.0.0 * @categories combinators */ (self: FiberSet, fiber: Fiber.RuntimeFiber, options?: { readonly interruptAs?: FiberId.FiberId | undefined; readonly propagateInterruption?: boolean | undefined; } | undefined): void; }; /** * Add a fiber to the FiberSet. When the fiber completes, it will be removed. * * @since 2.0.0 * @categories combinators */ export declare const add: { /** * Add a fiber to the FiberSet. When the fiber completes, it will be removed. * * @since 2.0.0 * @categories combinators */ (fiber: Fiber.RuntimeFiber, options?: { readonly propagateInterruption?: boolean | undefined; } | undefined): (self: FiberSet) => Effect.Effect; /** * Add a fiber to the FiberSet. When the fiber completes, it will be removed. * * @since 2.0.0 * @categories combinators */ (self: FiberSet, fiber: Fiber.RuntimeFiber, options?: { readonly propagateInterruption?: boolean | undefined; } | undefined): Effect.Effect; }; /** * @since 2.0.0 * @categories combinators */ export declare const clear: (self: FiberSet) => Effect.Effect; /** * Fork an Effect and add the forked fiber to the FiberSet. * When the fiber completes, it will be removed from the FiberSet. * * @since 2.0.0 * @categories combinators */ export declare const run: { /** * Fork an Effect and add the forked fiber to the FiberSet. * When the fiber completes, it will be removed from the FiberSet. * * @since 2.0.0 * @categories combinators */ (self: FiberSet, options?: { readonly propagateInterruption?: boolean | undefined; } | undefined): (effect: Effect.Effect) => Effect.Effect, never, R>; /** * Fork an Effect and add the forked fiber to the FiberSet. * When the fiber completes, it will be removed from the FiberSet. * * @since 2.0.0 * @categories combinators */ (self: FiberSet, effect: Effect.Effect, options?: { readonly propagateInterruption?: boolean | undefined; } | undefined): Effect.Effect, never, R>; }; /** * Capture a Runtime and use it to fork Effect's, adding the forked fibers to the FiberSet. * * @example * ```ts * import { Context, Effect, FiberSet } from "effect" * * interface Users { * readonly _: unique symbol * } * const Users = Context.GenericTag> * }>("Users") * * Effect.gen(function*() { * const set = yield* FiberSet.make() * const run = yield* FiberSet.runtime(set)() * * // run some effects and add the fibers to the set * run(Effect.andThen(Users, _ => _.getAll)) * }).pipe( * Effect.scoped // The fibers will be interrupted when the scope is closed * ) * ``` * * @since 2.0.0 * @categories combinators */ export declare const runtime: (self: FiberSet) => () => Effect.Effect<((effect: Effect.Effect, options?: Runtime.RunForkOptions & { readonly propagateInterruption?: boolean | undefined; } | undefined) => Fiber.RuntimeFiber), never, R>; /** * Capture a Runtime and use it to fork Effect's, adding the forked fibers to the FiberSet. * * The returned run function will return Promise's. * * @since 3.13.0 * @categories combinators */ export declare const runtimePromise: (self: FiberSet) => () => Effect.Effect<((effect: Effect.Effect, options?: (Runtime.RunForkOptions & { readonly propagateInterruption?: boolean | undefined; }) | undefined) => Promise), never, R>; /** * @since 2.0.0 * @categories combinators */ export declare const size: (self: FiberSet) => Effect.Effect; /** * Join all fibers in the FiberSet. If any of the Fiber's in the set terminate with a failure, * the returned Effect will terminate with the first failure that occurred. * * @since 2.0.0 * @categories combinators * @example * ```ts * import { Effect, FiberSet } from "effect"; * * Effect.gen(function* (_) { * const set = yield* _(FiberSet.make()); * yield* _(FiberSet.add(set, Effect.runFork(Effect.fail("error")))); * * // parent fiber will fail with "error" * yield* _(FiberSet.join(set)); * }); * ``` */ export declare const join: (self: FiberSet) => Effect.Effect; /** * Wait until the fiber set is empty. * * @since 3.13.0 * @categories combinators */ export declare const awaitEmpty: (self: FiberSet) => Effect.Effect; //# sourceMappingURL=FiberSet.d.ts.map