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

Method runLoop

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

Source from the content-addressed store, hash-verified

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