(fibers: ReadonlyArray<Fiber.RuntimeFiber<A, E>>)
| 5 | |
| 6 | /** @internal */ |
| 7 | export 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 | }) |
no test coverage detected