MCPcopy Create free account
hub / github.com/Effect-TS/effect / fiberAll

Function fiberAll

packages/effect/src/internal/fiberRuntime.ts:3448–3492  ·  view source on GitHub ↗
(fibers: Iterable<Fiber.Fiber<A, E>>)

Source from the content-addressed store, hash-verified

3446
3447/** @internal */
3448export const fiberAll = <A, E>(fibers: Iterable<Fiber.Fiber<A, E>>): Fiber.Fiber<Array<A>, E> => {
3449 const _fiberAll = {
3450 ...Effectable.CommitPrototype,
3451 commit() {
3452 return internalFiber.join(this)
3453 },
3454 [internalFiber.FiberTypeId]: internalFiber.fiberVariance,
3455 id: () =>
3456 RA.fromIterable(fibers).reduce((id, fiber) => FiberId.combine(id, fiber.id()), FiberId.none as FiberId.FiberId),
3457 await: core.exit(forEachParUnbounded(fibers, (fiber) => core.flatten(fiber.await), false)),
3458 children: core.map(forEachParUnbounded(fibers, (fiber) => fiber.children, false), RA.flatten),
3459 inheritAll: core.forEachSequentialDiscard(fibers, (fiber) => fiber.inheritAll),
3460 poll: core.map(
3461 core.forEachSequential(fibers, (fiber) => fiber.poll),
3462 RA.reduceRight(
3463 Option.some<Exit.Exit<Array<A>, E>>(core.exitSucceed(new Array())),
3464 (optionB, optionA) => {
3465 switch (optionA._tag) {
3466 case "None": {
3467 return Option.none()
3468 }
3469 case "Some": {
3470 switch (optionB._tag) {
3471 case "None": {
3472 return Option.none()
3473 }
3474 case "Some": {
3475 return Option.some(
3476 core.exitZipWith(optionA.value, optionB.value, {
3477 onSuccess: (a, chunk) => [a, ...chunk],
3478 onFailure: internalCause.parallel
3479 })
3480 )
3481 }
3482 }
3483 }
3484 }
3485 }
3486 )
3487 ),
3488 interruptAsFork: (fiberId: FiberId.FiberId) =>
3489 core.forEachSequentialDiscard(fibers, (fiber) => fiber.interruptAsFork(fiberId))
3490 }
3491 return _fiberAll
3492}
3493
3494/* @internal */
3495export const fiberInterruptFork = <A, E>(self: Fiber.Fiber<A, E>): Effect.Effect<void> =>

Callers 1

fiberJoinAllFunction · 0.85

Calls 5

forEachParUnboundedFunction · 0.85
combineMethod · 0.65
idMethod · 0.65
mapMethod · 0.65
interruptAsForkMethod · 0.65

Tested by

no test coverage detected