MCPcopy
hub / github.com/Effect-TS/effect / runLoop

Method runLoop

packages/effect/src/Micro.ts:540–568  ·  view source on GitHub ↗
(effect: Primitive)

Source from the content-addressed store, hash-verified

538 }
539
540 runLoop(effect: Primitive): MicroExit<A, E> | Yield {
541 let yielding = false
542 let current: Primitive | Yield = effect
543 this.currentOpCount = 0
544 try {
545 while (true) {
546 this.currentOpCount++
547 if (!yielding && this.getRef(CurrentScheduler).shouldYield(this as any)) {
548 yielding = true
549 const prev = current
550 current = flatMap(yieldNow, () => prev as any) as any
551 }
552 current = (current as any)[evaluate](this)
553 if (current === Yield) {
554 const yielded = this._yielded!
555 if (MicroExitTypeId in yielded) {
556 this._yielded = undefined
557 return yielded
558 }
559 return Yield
560 }
561 }
562 } catch (error) {
563 if (!hasProperty(current, evaluate)) {
564 return exitDie(`MicroFiber.runLoop: Not a valid effect: ${String(current)}`)
565 }
566 return exitDie(error)
567 }
568 }
569
570 getCont<S extends successCont | failureCont>(
571 symbol: S

Callers 1

evaluateMethod · 0.95

Calls 4

getRefMethod · 0.95
StringInterface · 0.85
exitDieFunction · 0.70
shouldYieldMethod · 0.65

Tested by

no test coverage detected