MCPcopy Index your code
hub / github.com/Effect-TS/effect / runImpl

Function runImpl

packages/effect/src/FiberMap.ts:478–501  ·  view source on GitHub ↗
(
  self: FiberMap<K, A, E>,
  key: K,
  effect: Effect.Effect<XA, XE, R>,
  options?: {
    readonly onlyIfMissing?: boolean
    readonly propagateInterruption?: boolean | undefined
  }
)

Source from the content-addressed store, hash-verified

476}
477
478const runImpl = <K, A, E, R, XE extends E, XA extends A>(
479 self: FiberMap<K, A, E>,
480 key: K,
481 effect: Effect.Effect<XA, XE, R>,
482 options?: {
483 readonly onlyIfMissing?: boolean
484 readonly propagateInterruption?: boolean | undefined
485 }
486) =>
487 Effect.withFiberRuntime((parent) => {
488 if (self.state._tag === "Closed") {
489 return Effect.interrupt
490 } else if (options?.onlyIfMissing === true && unsafeHas(self, key)) {
491 return Effect.sync(constInterruptedFiber)
492 }
493 const runtime = Runtime.make<R>({
494 context: parent.currentContext as any,
495 fiberRefs: parent.getFiberRefs(),
496 runtimeFlags: Runtime.defaultRuntime.runtimeFlags
497 })
498 const fiber = Runtime.runFork(runtime)(effect)
499 unsafeSet(self, key, fiber, { ...options, interruptAs: parent.id() })
500 return Effect.succeed(fiber)
501 })
502
503/**
504 * Capture a Runtime and use it to fork Effect's, adding the forked fibers to the FiberMap.

Callers 1

runFunction · 0.70

Calls 5

unsafeSetFunction · 0.85
syncMethod · 0.80
makeMethod · 0.65
getFiberRefsMethod · 0.65
idMethod · 0.65

Tested by

no test coverage detected