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

Function fiberInterruptAll

packages/effect/src/Micro.ts:637–658  ·  view source on GitHub ↗
(fibers: A)

Source from the content-addressed store, hash-verified

635 * @category MicroFiber
636 */
637export const fiberInterruptAll = <A extends Iterable<MicroFiber<any, any>>>(fibers: A): Micro<void> =>
638 suspend(() => {
639 for (const fiber of fibers) fiber.unsafeInterrupt()
640 const iter = fibers[Symbol.iterator]()
641 const wait: Micro<void> = suspend(() => {
642 let result = iter.next()
643 while (!result.done) {
644 if (result.value.unsafePoll()) {
645 result = iter.next()
646 continue
647 }
648 const fiber = result.value
649 return async((resume) => {
650 fiber.addObserver((_) => {
651 resume(wait)
652 })
653 })
654 }
655 return exitVoid
656 })
657 return wait
658 })
659
660const identifier = Symbol.for("effect/Micro/identifier")
661type identifier = typeof identifier

Callers 5

fiberInterruptChildrenFunction · 0.85
onExitFunction · 0.85
raceAllFunction · 0.85
raceAllFirstFunction · 0.85
forEachFunction · 0.85

Calls 7

asyncFunction · 0.85
unsafeInterruptMethod · 0.80
suspendFunction · 0.70
resumeFunction · 0.70
nextMethod · 0.65
unsafePollMethod · 0.65
addObserverMethod · 0.65

Tested by

no test coverage detected