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

Function runImpl

packages/effect/src/FiberHandle.ts:610–626  ·  view source on GitHub ↗
(
  self: FiberHandle<A, E>,
  effect: Effect.Effect<XA, XE, R>,
  options?: {
    readonly onlyIfMissing?: boolean | undefined
  }
)

Source from the content-addressed store, hash-verified

608}
609
610const runImpl = <A, E, R, XE extends E, XA extends A>(
611 self: FiberHandle<A, E>,
612 effect: Effect.Effect<XA, XE, R>,
613 options?: {
614 readonly onlyIfMissing?: boolean | undefined
615 }
616): Effect.Effect<Fiber.Fiber<XA, XE>, never, R> =>
617 Effect.withFiber((parent) => {
618 if (self.state._tag === "Closed") {
619 return Effect.interrupt
620 } else if (self.state.fiber !== undefined && options?.onlyIfMissing === true) {
621 return Effect.sync(constInterruptedFiber)
622 }
623 const fiber = Effect.runForkWith(parent.context as Context<R>)(effect)
624 setUnsafe(self, fiber, options)
625 return Effect.succeed(fiber)
626 })
627
628/**
629 * 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