import * as Deferred from "./Deferred.ts"; import * as Effect from "./Effect.ts"; import * as Fiber from "./Fiber.ts"; import type * as Inspectable from "./Inspectable.ts"; import * as MutableHashMap from "./MutableHashMap.ts"; import * as Option from "./Option.ts"; import type { Pipeable } from "./Pipeable.ts"; import type * as Scope from "./Scope.ts"; declare const TypeId = "~effect/FiberMap"; /** * A FiberMap is a collection of fibers, indexed by a key. When the associated * Scope is closed, all fibers in the map will be interrupted. Fibers are * automatically removed from the map when they complete. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * // Create a FiberMap with string keys * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add some fibers to the map * yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * yield* FiberMap.run(map, "task2", Effect.succeed("World")) * * // Get the size of the map * const size = yield* FiberMap.size(map) * console.log(size) // 2 * }) * ``` * * @since 2.0.0 * @category models */ export interface FiberMap extends Pipeable, Inspectable.Inspectable, Iterable<[K, Fiber.Fiber]> { readonly [TypeId]: typeof TypeId; readonly deferred: Deferred.Deferred; state: { readonly _tag: "Open"; readonly backing: MutableHashMap.MutableHashMap>; } | { readonly _tag: "Closed"; }; } /** * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * console.log(FiberMap.isFiberMap(map)) // true * console.log(FiberMap.isFiberMap({})) // false * console.log(FiberMap.isFiberMap(null)) // false * }) * ``` * * @since 2.0.0 * @category refinements */ export declare const isFiberMap: (u: unknown) => u is FiberMap; /** * A FiberMap can be used to store a collection of fibers, indexed by some key. * When the associated Scope is closed, all fibers in the map will be interrupted. * * You can add fibers to the map using `FiberMap.set` or `FiberMap.run`, and the fibers will * be automatically removed from the FiberMap when they complete. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * Effect.gen(function*() { * const map = yield* FiberMap.make() * * // run some effects and add the fibers to the map * yield* FiberMap.run(map, "fiber a", Effect.never) * yield* FiberMap.run(map, "fiber b", Effect.never) * * yield* Effect.sleep(1000) * }).pipe( * Effect.scoped // The fibers will be interrupted when the scope is closed * ) * ``` * * @since 2.0.0 * @category constructors */ export declare const make: () => Effect.Effect, never, Scope.Scope>; /** * Create an Effect run function that is backed by a FiberMap. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const run = yield* FiberMap.makeRuntime() * * // Run effects and get back fibers * const fiber1 = run("task1", Effect.succeed("Hello")) * const fiber2 = run("task2", Effect.succeed("World")) * * // Await the results * const result1 = yield* Fiber.await(fiber1) * const result2 = yield* Fiber.await(fiber2) * * console.log(result1, result2) // "Hello", "World" * }) * ``` * * @since 2.0.0 * @category constructors */ export declare const makeRuntime: () => Effect.Effect<((key: K, effect: Effect.Effect, options?: (Effect.RunOptions & { readonly onlyIfMissing?: boolean | undefined; }) | undefined) => Fiber.Fiber), never, Scope.Scope | R>; /** * Create an Effect run function that is backed by a FiberMap. * Returns a Promise instead of a Fiber for more convenient use with async/await. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const run = yield* FiberMap.makeRuntimePromise() * * // Run effects and get back promises * const promise1 = run("task1", Effect.succeed("Hello")) * const promise2 = run("task2", Effect.succeed("World")) * * // Convert to Effect and await * const result1 = yield* Effect.promise(() => promise1) * const result2 = yield* Effect.promise(() => promise2) * * console.log(result1, result2) // "Hello", "World" * }) * ``` * * @since 3.13.0 * @category constructors */ export declare const makeRuntimePromise: () => Effect.Effect<((key: K, effect: Effect.Effect, options?: (Effect.RunOptions & { readonly onlyIfMissing?: boolean | undefined; }) | undefined) => Promise), never, Scope.Scope | R>; /** * Add a fiber to the FiberMap. When the fiber completes, it will be removed from the FiberMap. * If the key already exists in the FiberMap, the previous fiber will be interrupted. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Create a fiber and add it to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * FiberMap.setUnsafe(map, "greeting", fiber) * * // The fiber will be automatically removed when it completes * const result = yield* Fiber.await(fiber) * console.log(result) // "Hello" * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const setUnsafe: { /** * Add a fiber to the FiberMap. When the fiber completes, it will be removed from the FiberMap. * If the key already exists in the FiberMap, the previous fiber will be interrupted. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Create a fiber and add it to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * FiberMap.setUnsafe(map, "greeting", fiber) * * // The fiber will be automatically removed when it completes * const result = yield* Fiber.await(fiber) * console.log(result) // "Hello" * }) * ``` * * @since 2.0.0 * @category combinators */ (key: K, fiber: Fiber.Fiber, options?: { readonly onlyIfMissing?: boolean | undefined; readonly propagateInterruption?: boolean | undefined; } | undefined): (self: FiberMap) => void; /** * Add a fiber to the FiberMap. When the fiber completes, it will be removed from the FiberMap. * If the key already exists in the FiberMap, the previous fiber will be interrupted. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Create a fiber and add it to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * FiberMap.setUnsafe(map, "greeting", fiber) * * // The fiber will be automatically removed when it completes * const result = yield* Fiber.await(fiber) * console.log(result) // "Hello" * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K, fiber: Fiber.Fiber, options?: { readonly onlyIfMissing?: boolean | undefined; readonly propagateInterruption?: boolean | undefined; } | undefined): void; }; /** * Add a fiber to the FiberMap. When the fiber completes, it will be removed from the FiberMap. * If the key already exists in the FiberMap, the previous fiber will be interrupted. * This is the Effect-wrapped version of `setUnsafe`. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Create a fiber and add it to the map using Effect * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * yield* FiberMap.set(map, "greeting", fiber) * * // The fiber will be automatically removed when it completes * const result = yield* Fiber.await(fiber) * console.log(result) // "Hello" * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const set: { /** * Add a fiber to the FiberMap. When the fiber completes, it will be removed from the FiberMap. * If the key already exists in the FiberMap, the previous fiber will be interrupted. * This is the Effect-wrapped version of `setUnsafe`. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Create a fiber and add it to the map using Effect * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * yield* FiberMap.set(map, "greeting", fiber) * * // The fiber will be automatically removed when it completes * const result = yield* Fiber.await(fiber) * console.log(result) // "Hello" * }) * ``` * * @since 2.0.0 * @category combinators */ (key: K, fiber: Fiber.Fiber, options?: { readonly onlyIfMissing?: boolean | undefined; readonly propagateInterruption?: boolean | undefined; } | undefined): (self: FiberMap) => Effect.Effect; /** * Add a fiber to the FiberMap. When the fiber completes, it will be removed from the FiberMap. * If the key already exists in the FiberMap, the previous fiber will be interrupted. * This is the Effect-wrapped version of `setUnsafe`. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Create a fiber and add it to the map using Effect * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * yield* FiberMap.set(map, "greeting", fiber) * * // The fiber will be automatically removed when it completes * const result = yield* Fiber.await(fiber) * console.log(result) // "Hello" * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K, fiber: Fiber.Fiber, options?: { readonly onlyIfMissing?: boolean | undefined; readonly propagateInterruption?: boolean | undefined; } | undefined): Effect.Effect; }; /** * Retrieve a fiber from the FiberMap. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * FiberMap.setUnsafe(map, "greeting", fiber) * * // Retrieve the fiber * const retrieved = FiberMap.getUnsafe(map, "greeting") * if (retrieved._tag === "Some") { * const result = yield* Fiber.await(retrieved.value) * console.log(result) // "Hello" * } * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const getUnsafe: { /** * Retrieve a fiber from the FiberMap. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * FiberMap.setUnsafe(map, "greeting", fiber) * * // Retrieve the fiber * const retrieved = FiberMap.getUnsafe(map, "greeting") * if (retrieved._tag === "Some") { * const result = yield* Fiber.await(retrieved.value) * console.log(result) // "Hello" * } * }) * ``` * * @since 2.0.0 * @category combinators */ (key: K): (self: FiberMap) => Option.Option>; /** * Retrieve a fiber from the FiberMap. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * FiberMap.setUnsafe(map, "greeting", fiber) * * // Retrieve the fiber * const retrieved = FiberMap.getUnsafe(map, "greeting") * if (retrieved._tag === "Some") { * const result = yield* Fiber.await(retrieved.value) * console.log(result) // "Hello" * } * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K): Option.Option>; }; /** * Retrieve a fiber from the FiberMap. * * Returns an `Option` wrapped in `Effect`. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * yield* FiberMap.set(map, "greeting", fiber) * * // Retrieve the fiber with error handling * const retrieved = yield* FiberMap.get(map, "greeting") * if (retrieved._tag === "Some") { * const result = yield* Fiber.await(retrieved.value) * console.log(result) // "Hello" * } * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const get: { /** * Retrieve a fiber from the FiberMap. * * Returns an `Option` wrapped in `Effect`. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * yield* FiberMap.set(map, "greeting", fiber) * * // Retrieve the fiber with error handling * const retrieved = yield* FiberMap.get(map, "greeting") * if (retrieved._tag === "Some") { * const result = yield* Fiber.await(retrieved.value) * console.log(result) // "Hello" * } * }) * ``` * * @since 2.0.0 * @category combinators */ (key: K): (self: FiberMap) => Effect.Effect>>; /** * Retrieve a fiber from the FiberMap. * * Returns an `Option` wrapped in `Effect`. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * const fiber = yield* Effect.forkChild(Effect.succeed("Hello")) * yield* FiberMap.set(map, "greeting", fiber) * * // Retrieve the fiber with error handling * const retrieved = yield* FiberMap.get(map, "greeting") * if (retrieved._tag === "Some") { * const result = yield* Fiber.await(retrieved.value) * console.log(result) // "Hello" * } * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K): Effect.Effect>>; }; /** * Check if a key exists in the FiberMap. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * * // Check if keys exist * console.log(FiberMap.hasUnsafe(map, "task1")) // true * console.log(FiberMap.hasUnsafe(map, "task2")) // false * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const hasUnsafe: { /** * Check if a key exists in the FiberMap. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * * // Check if keys exist * console.log(FiberMap.hasUnsafe(map, "task1")) // true * console.log(FiberMap.hasUnsafe(map, "task2")) // false * }) * ``` * * @since 2.0.0 * @category combinators */ (key: K): (self: FiberMap) => boolean; /** * Check if a key exists in the FiberMap. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * * // Check if keys exist * console.log(FiberMap.hasUnsafe(map, "task1")) // true * console.log(FiberMap.hasUnsafe(map, "task2")) // false * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K): boolean; }; /** * Check if a key exists in the FiberMap. * This is the Effect-wrapped version of `hasUnsafe`. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * * // Check if keys exist using Effect * const exists1 = yield* FiberMap.has(map, "task1") * const exists2 = yield* FiberMap.has(map, "task2") * * console.log(exists1) // true * console.log(exists2) // false * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const has: { /** * Check if a key exists in the FiberMap. * This is the Effect-wrapped version of `hasUnsafe`. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * * // Check if keys exist using Effect * const exists1 = yield* FiberMap.has(map, "task1") * const exists2 = yield* FiberMap.has(map, "task2") * * console.log(exists1) // true * console.log(exists2) // false * }) * ``` * * @since 2.0.0 * @category combinators */ (key: K): (self: FiberMap) => Effect.Effect; /** * Check if a key exists in the FiberMap. * This is the Effect-wrapped version of `hasUnsafe`. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add a fiber to the map * yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * * // Check if keys exist using Effect * const exists1 = yield* FiberMap.has(map, "task1") * const exists2 = yield* FiberMap.has(map, "task2") * * console.log(exists1) // true * console.log(exists2) // false * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K): Effect.Effect; }; /** * Remove a fiber from the FiberMap, interrupting it if it exists. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add some fibers to the map * yield* FiberMap.run(map, "task1", Effect.never) * yield* FiberMap.run(map, "task2", Effect.never) * * console.log(yield* FiberMap.size(map)) // 2 * * // Remove a specific fiber (this will interrupt it) * yield* FiberMap.remove(map, "task1") * * console.log(yield* FiberMap.size(map)) // 1 * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const remove: { /** * Remove a fiber from the FiberMap, interrupting it if it exists. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add some fibers to the map * yield* FiberMap.run(map, "task1", Effect.never) * yield* FiberMap.run(map, "task2", Effect.never) * * console.log(yield* FiberMap.size(map)) // 2 * * // Remove a specific fiber (this will interrupt it) * yield* FiberMap.remove(map, "task1") * * console.log(yield* FiberMap.size(map)) // 1 * }) * ``` * * @since 2.0.0 * @category combinators */ (key: K): (self: FiberMap) => Effect.Effect; /** * Remove a fiber from the FiberMap, interrupting it if it exists. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add some fibers to the map * yield* FiberMap.run(map, "task1", Effect.never) * yield* FiberMap.run(map, "task2", Effect.never) * * console.log(yield* FiberMap.size(map)) // 2 * * // Remove a specific fiber (this will interrupt it) * yield* FiberMap.remove(map, "task1") * * console.log(yield* FiberMap.size(map)) // 1 * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K): Effect.Effect; }; /** * Remove all fibers from the FiberMap, interrupting them. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add some fibers to the map * yield* FiberMap.run(map, "task1", Effect.never) * yield* FiberMap.run(map, "task2", Effect.never) * yield* FiberMap.run(map, "task3", Effect.never) * * console.log(yield* FiberMap.size(map)) // 3 * * // Clear all fibers (this will interrupt all of them) * yield* FiberMap.clear(map) * * console.log(yield* FiberMap.size(map)) // 0 * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const clear: (self: FiberMap) => Effect.Effect; /** * Run an Effect and add the forked fiber to the FiberMap. * When the fiber completes, it will be removed from the FiberMap. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Run effects and add the fibers to the map * const fiber1 = yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * const fiber2 = yield* FiberMap.run(map, "task2", Effect.succeed("World")) * * // Wait for the results * const result1 = yield* Fiber.await(fiber1) * const result2 = yield* Fiber.await(fiber2) * * console.log(result1, result2) // "Hello", "World" * console.log(yield* FiberMap.size(map)) // 0 (fibers are removed after completion) * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const run: { /** * Run an Effect and add the forked fiber to the FiberMap. * When the fiber completes, it will be removed from the FiberMap. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Run effects and add the fibers to the map * const fiber1 = yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * const fiber2 = yield* FiberMap.run(map, "task2", Effect.succeed("World")) * * // Wait for the results * const result1 = yield* Fiber.await(fiber1) * const result2 = yield* Fiber.await(fiber2) * * console.log(result1, result2) // "Hello", "World" * console.log(yield* FiberMap.size(map)) // 0 (fibers are removed after completion) * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K, options?: { readonly onlyIfMissing?: boolean | undefined; readonly propagateInterruption?: boolean | undefined; readonly startImmediately?: boolean | undefined; } | undefined): (effect: Effect.Effect) => Effect.Effect, never, R>; /** * Run an Effect and add the forked fiber to the FiberMap. * When the fiber completes, it will be removed from the FiberMap. * * @example * ```ts * import { Effect, Fiber, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Run effects and add the fibers to the map * const fiber1 = yield* FiberMap.run(map, "task1", Effect.succeed("Hello")) * const fiber2 = yield* FiberMap.run(map, "task2", Effect.succeed("World")) * * // Wait for the results * const result1 = yield* Fiber.await(fiber1) * const result2 = yield* Fiber.await(fiber2) * * console.log(result1, result2) // "Hello", "World" * console.log(yield* FiberMap.size(map)) // 0 (fibers are removed after completion) * }) * ``` * * @since 2.0.0 * @category combinators */ (self: FiberMap, key: K, effect: Effect.Effect, options?: { readonly onlyIfMissing?: boolean | undefined; readonly propagateInterruption?: boolean | undefined; readonly startImmediately?: boolean | undefined; } | undefined): Effect.Effect, never, R>; }; /** * Capture a Runtime and use it to fork Effect's, adding the forked fibers to the FiberMap. * * @example * ```ts * import { Effect, FiberMap, Context } from "effect" * * interface Users { * readonly _: unique symbol * } * const Users = Context.Service> * }>("Users") * * Effect.gen(function*() { * const map = yield* FiberMap.make() * const run = yield* FiberMap.runtime(map)() * * // run some effects and add the fibers to the map * run("effect-a", Effect.andThen(Users, (_) => _.getAll)) * run("effect-b", Effect.andThen(Users, (_) => _.getAll)) * }).pipe( * Effect.scoped // The fibers will be interrupted when the scope is closed * ) * ``` * * @since 2.0.0 * @category combinators */ export declare const runtime: (self: FiberMap) => () => Effect.Effect<((key: K, effect: Effect.Effect, options?: Effect.RunOptions & { readonly onlyIfMissing?: boolean | undefined; readonly propagateInterruption?: boolean | undefined; } | undefined) => Fiber.Fiber), never, R>; /** * Capture a Runtime and use it to fork Effect's, adding the forked fibers to the FiberMap. * Returns a Promise instead of a Fiber for convenience. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * const runPromise = yield* FiberMap.runtimePromise(map)() * * // Create promises that will be backed by fibers in the map * const promise1 = runPromise("task1", Effect.succeed("Hello")) * const promise2 = runPromise("task2", Effect.succeed("World")) * * // Convert promises back to Effects and await * const result1 = yield* Effect.promise(() => promise1) * const result2 = yield* Effect.promise(() => promise2) * * console.log(result1, result2) // "Hello", "World" * }) * ``` * * @since 3.13.0 * @category combinators */ export declare const runtimePromise: (self: FiberMap) => () => Effect.Effect<((key: K, effect: Effect.Effect, options?: (Effect.RunOptions & { readonly onlyIfMissing?: boolean | undefined; readonly propagateInterruption?: boolean | undefined; }) | undefined) => Promise), never, R>; /** * Get the number of fibers currently in the FiberMap. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * console.log(yield* FiberMap.size(map)) // 0 * * // Add some fibers * yield* FiberMap.run(map, "task1", Effect.never) * yield* FiberMap.run(map, "task2", Effect.never) * * console.log(yield* FiberMap.size(map)) // 2 * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const size: (self: FiberMap) => Effect.Effect; /** * Join all fibers in the FiberMap. If any of the Fiber's in the map terminate with a failure, * the returned Effect will terminate with the first failure that occurred. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * Effect.gen(function*() { * const map = yield* FiberMap.make() * yield* FiberMap.set(map, "a", Effect.runFork(Effect.fail("error"))) * * // parent fiber will fail with "error" * yield* FiberMap.join(map) * }) * ``` * * @since 2.0.0 * @category combinators */ export declare const join: (self: FiberMap) => Effect.Effect; /** * Wait for the FiberMap to be empty. * This will wait for all currently running fibers to complete. * * @example * ```ts * import { Effect, FiberMap } from "effect" * * const program = Effect.gen(function*() { * const map = yield* FiberMap.make() * * // Add some fibers that will complete after a delay * yield* FiberMap.run(map, "task1", Effect.sleep(1000)) * yield* FiberMap.run(map, "task2", Effect.sleep(2000)) * * console.log("Waiting for all fibers to complete...") * * // Wait for the map to be empty * yield* FiberMap.awaitEmpty(map) * * console.log("All fibers completed!") * console.log(yield* FiberMap.size(map)) // 0 * }) * ``` * * @since 3.13.0 * @category combinators */ export declare const awaitEmpty: (self: FiberMap) => Effect.Effect; export {}; //# sourceMappingURL=FiberMap.d.ts.map