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

Function fiberInterruptAll

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

Source from the content-addressed store, hash-verified

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