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

Method evaluateEffect

packages/effect/src/internal/fiberRuntime.ts:941–988  ·  view source on GitHub ↗

* Evaluates an effect until completion, potentially asynchronously. * * **NOTE**: This method must be invoked by the fiber itself.

(effect0: Effect.Effect<any, any, any>)

Source from the content-addressed store, hash-verified

939 * **NOTE**: This method must be invoked by the fiber itself.
940 */
941 evaluateEffect(effect0: Effect.Effect<any, any, any>) {
942 this.currentSupervisor.onResume(this)
943 try {
944 let effect: Effect.Effect<any, any, any> | null =
945 runtimeFlags_.interruptible(this.currentRuntimeFlags) && this.isInterrupted() ?
946 core.exitFailCause(this.getInterruptedCause()) :
947 effect0
948 while (effect !== null) {
949 const eff: Effect.Effect<any, any, any> = effect
950 const exit = this.runLoop(eff)
951 if (exit === YieldedOp) {
952 const op = yieldedOpChannel.currentOp!
953 yieldedOpChannel.currentOp = null
954 if (op._op === OpCodes.OP_YIELD) {
955 if (runtimeFlags_.cooperativeYielding(this.currentRuntimeFlags)) {
956 this.tell(FiberMessage.yieldNow())
957 this.tell(FiberMessage.resume(core.exitVoid))
958 effect = null
959 } else {
960 effect = core.exitVoid
961 }
962 } else if (op._op === OpCodes.OP_ASYNC) {
963 // Terminate this evaluation, async resumption will continue evaluation:
964 effect = null
965 }
966 } else {
967 this.currentRuntimeFlags = pipe(this.currentRuntimeFlags, runtimeFlags_.enable(runtimeFlags_.WindDown))
968 const interruption = this.interruptAllChildren()
969 if (interruption !== null) {
970 effect = core.flatMap(interruption, () => exit)
971 } else {
972 if (this._queue.length === 0) {
973 // No more messages to process, so we will allow the fiber to end life:
974 this.setExitValue(exit)
975 } else {
976 // There are messages, possibly added by the final op executed by
977 // the fiber. To be safe, we should execute those now before we
978 // allow the fiber to end life:
979 this.tell(FiberMessage.resume(exit))
980 }
981 effect = null
982 }
983 }
984 }
985 } finally {
986 this.currentSupervisor.onSuspend(this)
987 }
988 }
989
990 /**
991 * Begins execution of the effect associated with this fiber on the current

Callers 2

startMethod · 0.95

Calls 10

isInterruptedMethod · 0.95
getInterruptedCauseMethod · 0.95
runLoopMethod · 0.95
tellMethod · 0.95
interruptAllChildrenMethod · 0.95
setExitValueMethod · 0.95
resumeMethod · 0.80
pipeFunction · 0.70
onResumeMethod · 0.65
onSuspendMethod · 0.65

Tested by

no test coverage detected