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

Function runtime

packages/effect/src/FiberHandle.ts:440–464  ·  view source on GitHub ↗
(self: FiberHandle<A, E>)

Source from the content-addressed store, hash-verified

438 never,
439 R
440> = <A, E>(self: FiberHandle<A, E>) => <R>() =>
441 Effect.map(
442 Effect.runtime<R>(),
443 (runtime) => {
444 const runFork = Runtime.runFork(runtime)
445 return <XE extends E, XA extends A>(
446 effect: Effect.Effect<XA, XE, R>,
447 options?:
448 | Runtime.RunForkOptions & {
449 readonly onlyIfMissing?: boolean | undefined
450 readonly propagateInterruption?: boolean | undefined
451 }
452 | undefined
453 ) => {
454 if (self.state._tag === "Closed") {
455 return constInterruptedFiber()
456 } else if (self.state.fiber !== undefined && options?.onlyIfMissing === true) {
457 return constInterruptedFiber()
458 }
459 const fiber = runFork(effect, options)
460 unsafeSet(self, fiber, options)
461 return fiber
462 }
463 }
464 )
465
466/**
467 * Capture a Runtime and use it to fork Effect's, adding the forked fibers to the FiberHandle.

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