<K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>Waits for the FiberMap to fail or close.
Details
The returned Effect fails with the first managed fiber failure that is not
ignored by the map's interruption rules. Normal successful completion
removes fibers from the map; use awaitEmpty to wait until the map has no
fibers.
Example (Joining failing fibers)
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)
})export const const join: <K, A, E>(
self: FiberMap<K, A, E>
) => Effect.Effect<void, E>
Waits for the FiberMap to fail or close.
Details
The returned Effect fails with the first managed fiber failure that is not
ignored by the map's interruption rules. Normal successful completion
removes fibers from the map; use awaitEmpty to wait until the map has no
fibers.
Example (Joining failing fibers)
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)
})
join = <function (type parameter) K in <K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>K, function (type parameter) A in <K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>A, function (type parameter) E in <K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>E>(self: FiberMap<K, A, E>(parameter) self: {
deferred: Deferred.Deferred<void, unknown>;
state: { readonly _tag: "Open"; readonly backing: MutableHashMap.MutableHashMap<K, Fiber.Fiber<A, E>> } | { readonly _tag: "Closed" };
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;
}
self: interface FiberMap<in out K, out A = unknown, out E = unknown>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 (Managing fibers in a map)
import { Effect, FiberMap } from "effect"
// Create a FiberMap with string keys
const program = Effect.gen(function*() {
const map = yield* FiberMap.make<string>()
// Add some fibers to the map
yield* FiberMap.run(map, "task1", Effect.never)
yield* FiberMap.run(map, "task2", Effect.never)
// Get the size of the map
const size = yield* FiberMap.size(map)
console.log(size) // 2
})
FiberMap<function (type parameter) K in <K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>K, function (type parameter) A in <K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>A, function (type parameter) E in <K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>E>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void, function (type parameter) E in <K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>E> =>
import DeferredDeferred.await(self: FiberMap<K, A, E>(parameter) self: {
deferred: Deferred.Deferred<void, unknown>;
state: { readonly _tag: "Open"; readonly backing: MutableHashMap.MutableHashMap<K, Fiber.Fiber<A, E>> } | { readonly _tag: "Closed" };
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;
}
self.FiberMap<in out K, out A = unknown, out E = unknown>.deferred: Deferred.Deferred<void, unknown>(property) FiberMap<in out K, out A = unknown, out E = unknown>.deferred: {
effect: Effect<A, E>;
resumes: Array<(effect: Effect<A, E>) => void> | 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; <…;
}
deferred as import DeferredDeferred.type Deferred.Deferred = /*unresolved*/ anyDeferred<void, function (type parameter) E in <K, A, E>(self: FiberMap<K, A, E>): Effect.Effect<void, E>E>)