MCPcopy Index your code
hub / github.com/Effect-TS/effect / joinAllDiscard

Function joinAllDiscard

packages/cluster/src/internal/fiber.ts:7–35  ·  view source on GitHub ↗
(fibers: ReadonlyArray<Fiber.RuntimeFiber<A, E>>)

Source from the content-addressed store, hash-verified

5
6/** @internal */
7export const joinAllDiscard = <A, E>(fibers: ReadonlyArray<Fiber.RuntimeFiber<A, E>>) =>
8 Effect.async<void, E>((resume) => {
9 let cause: Cause.Cause<E> | undefined = undefined
10 let i = 0
11 function loop() {
12 while (i < fibers.length) {
13 const fiber = fibers[i]
14 const exit = fiber.unsafePoll()
15 if (exit) {
16 i++
17 if (exit._tag === "Success") continue
18 cause = cause ? Cause.parallel(cause, exit.cause) : exit.cause
19 continue
20 }
21 fiber.addObserver(onExit)
22 return
23 }
24 resume(cause ? Effect.failCause(cause) : Effect.void)
25 }
26 function onExit(exit: Exit.Exit<A, E>) {
27 i++
28 if (exit._tag === "Failure") {
29 cause = cause ? Cause.parallel(cause, exit.cause) : exit.cause
30 }
31 loop()
32 }
33 loop()
34 return Effect.sync(() => fibers[i].removeObserver(onExit))
35 })

Callers 2

Sharding.tsFile · 0.85
entityManager.tsFile · 0.85

Calls 3

syncMethod · 0.80
loopFunction · 0.70
removeObserverMethod · 0.65

Tested by

no test coverage detected