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

Function go

packages/effect/src/internal/channel.ts:1686–1769  ·  view source on GitHub ↗
(
        state: State
      )

Source from the content-addressed store, hash-verified

1684 }
1685
1686 function go(
1687 state: State
1688 ): Channel.Channel<
1689 OutElem | OutElem1,
1690 unknown,
1691 OutErr2 | OutErr3,
1692 unknown,
1693 OutDone2 | OutDone3,
1694 unknown,
1695 Env | Env1
1696 > {
1697 switch (state._tag) {
1698 case MergeStateOpCodes.OP_BOTH_RUNNING: {
1699 const leftJoin = Effect.interruptible(Fiber.join(state.left))
1700 const rightJoin = Effect.interruptible(Fiber.join(state.right))
1701 return unwrap(
1702 Effect.raceWith(leftJoin, rightJoin, {
1703 onSelfDone: (leftExit, rf) =>
1704 Effect.zipRight(
1705 Fiber.interrupt(rf),
1706 handleSide(leftExit, state.right, pullL)(
1707 options.onSelfDone,
1708 mergeState.BothRunning,
1709 (f) => mergeState.LeftDone(f)
1710 )
1711 ),
1712 onOtherDone: (rightExit, lf) =>
1713 Effect.zipRight(
1714 Fiber.interrupt(lf),
1715 handleSide(rightExit, state.left, pullR)(
1716 options.onOtherDone as (
1717 ex: Exit.Exit<OutDone1, InErr1 | OutErr1>
1718 ) => MergeDecision.MergeDecision<
1719 Env1 | Env,
1720 OutErr,
1721 OutDone,
1722 OutErr2 | OutErr3,
1723 OutDone2 | OutDone3
1724 >,
1725 (left, right) => mergeState.BothRunning(right, left),
1726 (f) => mergeState.RightDone(f)
1727 )
1728 )
1729 })
1730 )
1731 }
1732 case MergeStateOpCodes.OP_LEFT_DONE: {
1733 return unwrap(
1734 Effect.map(
1735 Effect.exit(pullR),
1736 Exit.match({
1737 onFailure: (cause) => core.fromEffect(state.f(Exit.failCause(cause))),
1738 onSuccess: Either.match({
1739 onLeft: (done) => core.fromEffect(state.f(Exit.succeed(done))),
1740 onRight: (elem) =>
1741 core.flatMap(
1742 core.write(elem),
1743 () => go(mergeState.LeftDone(state.f))

Callers 2

onDecisionFunction · 0.70
handleSideFunction · 0.70

Calls 9

fromEffectMethod · 0.80
failCauseMethod · 0.80
unwrapFunction · 0.70
handleSideFunction · 0.70
joinMethod · 0.65
mapMethod · 0.65
fMethod · 0.65
writeMethod · 0.65
interruptMethod · 0.45

Tested by

no test coverage detected