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

Function runImpl

packages/effect/src/FiberMap.ts:789–807  ·  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

787}
788
789const runImpl = <K, A, E, R, XE extends E, XA extends A>(
790 self: FiberMap<K, A, E>,
791 key: K,
792 effect: Effect.Effect<XA, XE, R>,
793 options?: {
794 readonly onlyIfMissing?: boolean
795 readonly propagateInterruption?: boolean | undefined
796 }
797) =>
798 Effect.withFiber((parent) => {
799 if (self.state._tag === "Closed") {
800 return Effect.interrupt
801 } else if (options?.onlyIfMissing === true && hasUnsafe(self, key)) {
802 return Effect.sync(constInterruptedFiber)
803 }
804 const fiber = Effect.runForkWith(parent.context as Context<R>)(effect)
805 setUnsafe(self, key, fiber, options)
806 return Effect.succeed(fiber)
807 })
808
809/**
810 * Captures the current runtime and returns a function for forking effects into

Callers 1

runFunction · 0.70

Calls 3

setUnsafeFunction · 0.85
syncMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected