(all: Iterable<Effect.Effect<A, E, R>>)
| 2665 | export const raceAll: <Eff extends Effect.Effect<any, any, any>>( |
| 2666 | all: Iterable<Eff> |
| 2667 | ) => Effect.Effect<Effect.Effect.Success<Eff>, Effect.Effect.Error<Eff>, Effect.Effect.Context<Eff>> = < |
| 2668 | A, |
| 2669 | E, |
| 2670 | R |
| 2671 | >(all: Iterable<Effect.Effect<A, E, R>>): Effect.Effect<A, E, R> => |
| 2672 | core.withFiberRuntime((state, status) => |
| 2673 | core.async<A, E, R>((resume) => { |
| 2674 | const fibers = new Set<FiberRuntime<A, E>>() |
| 2675 | let winner: FiberRuntime<A, E> | undefined |
| 2676 | let failures: Cause.Cause<E> = internalCause.empty |
| 2677 | const interruptAll = () => { |
| 2678 | for (const fiber of fibers) { |
| 2679 | fiber.unsafeInterruptAsFork(state.id()) |
| 2680 | } |
| 2681 | } |
| 2682 | let latch = false |
| 2683 | let empty = true |
| 2684 | for (const self of all) { |
| 2685 | empty = false |
| 2686 | const fiber = unsafeFork( |
| 2687 | core.interruptible(self), |
| 2688 | state, |
| 2689 | status.runtimeFlags |
| 2690 | ) |
| 2691 | fibers.add(fiber) |
| 2692 | fiber.addObserver((exit) => { |
| 2693 | fibers.delete(fiber) |
| 2694 | if (!winner) { |
| 2695 | if (exit._tag === "Success") { |
| 2696 | latch = true |
| 2697 | winner = fiber |
| 2698 | failures = internalCause.empty |
| 2699 | interruptAll() |
| 2700 | } else { |
| 2701 | failures = internalCause.parallel(exit.cause, failures) |
| 2702 | } |
| 2703 | } |
| 2704 | if (latch && fibers.size === 0) { |
| 2705 | resume( |
| 2706 | winner ? core.zipRight(internalFiber.inheritAll(winner), winner.unsafePoll()!) : core.failCause(failures) |
| 2707 | ) |
| 2708 | } |
| 2709 | }) |
| 2710 | if (winner) break |
| 2711 | } |
| 2712 | if (empty) { |
| 2713 | return resume(core.dieSync(() => new core.IllegalArgumentException(`Received an empty collection of effects`))) |
| 2714 | } |
| 2715 | latch = true |
| 2716 | return internalFiber.interruptAllAs(fibers, state.id()) |
| 2717 | }) |
| 2718 | ) |
| 2719 | |
| 2720 | /* @internal */ |
| 2721 | export const reduceEffect = dual< |
nothing calls this directly
no test coverage detected