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

Function runtime

packages/effect/src/FiberMap.ts:547–572  ·  view source on GitHub ↗
(self: FiberMap<K, A, E>)

Source from the content-addressed store, hash-verified

545 never,
546 R
547> = <K, A, E>(self: FiberMap<K, A, E>) => <R>() =>
548 Effect.map(
549 Effect.runtime<R>(),
550 (runtime) => {
551 const runFork = Runtime.runFork(runtime)
552 return <XE extends E, XA extends A>(
553 key: K,
554 effect: Effect.Effect<XA, XE, R>,
555 options?:
556 | Runtime.RunForkOptions & {
557 readonly onlyIfMissing?: boolean | undefined
558 readonly propagateInterruption?: boolean | undefined
559 }
560 | undefined
561 ) => {
562 if (self.state._tag === "Closed") {
563 return constInterruptedFiber()
564 } else if (options?.onlyIfMissing === true && unsafeHas(self, key)) {
565 return constInterruptedFiber()
566 }
567 const fiber = runFork(effect, options)
568 unsafeSet(self, key, fiber, options)
569 return fiber
570 }
571 }
572 )
573
574/**
575 * Capture a Runtime and use it to fork Effect's, adding the forked fibers to the FiberMap.

Callers 2

makeRuntimeFunction · 0.70
runtimePromiseFunction · 0.70

Calls 4

unsafeSetFunction · 0.85
runtimeMethod · 0.80
runForkFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected