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

Function runImpl

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

Source from the content-addressed store, hash-verified

369}
370
371const runImpl = <A, E, R, XE extends E, XA extends A>(
372 self: FiberHandle<A, E>,
373 effect: Effect.Effect<XA, XE, R>,
374 options?: {
375 readonly onlyIfMissing?: boolean
376 readonly propagateInterruption?: boolean | undefined
377 }
378): Effect.Effect<Fiber.RuntimeFiber<XA, XE>, never, R> =>
379 Effect.withFiberRuntime((parent) => {
380 if (self.state._tag === "Closed") {
381 return Effect.interrupt
382 } else if (self.state.fiber !== undefined && options?.onlyIfMissing === true) {
383 return Effect.sync(constInterruptedFiber)
384 }
385 const runtime = Runtime.make<R>({
386 context: parent.currentContext as any,
387 fiberRefs: parent.getFiberRefs(),
388 runtimeFlags: Runtime.defaultRuntime.runtimeFlags
389 })
390 const fiber = Runtime.runFork(runtime)(effect)
391 unsafeSet(self, fiber, { ...options, interruptAs: parent.id() })
392 return Effect.succeed(fiber)
393 })
394
395/**
396 * Capture a Runtime and use it to fork Effect's, adding the forked fibers to the FiberHandle.

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