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

Function runtime

packages/effect/src/FiberMap.ts:863–888  ·  view source on GitHub ↗
(self: FiberMap<K, A, E>)

Source from the content-addressed store, hash-verified

861 never,
862 R
863> = <K, A, E>(self: FiberMap<K, A, E>) => <R>() =>
864 Effect.map(
865 Effect.context<R>(),
866 (services) => {
867 const runFork = Effect.runForkWith(services)
868 return <XE extends E, XA extends A>(
869 key: K,
870 effect: Effect.Effect<XA, XE, R>,
871 options?:
872 | Effect.RunOptions & {
873 readonly onlyIfMissing?: boolean | undefined
874 readonly propagateInterruption?: boolean | undefined
875 }
876 | undefined
877 ) => {
878 if (self.state._tag === "Closed") {
879 return constInterruptedFiber()
880 } else if (options?.onlyIfMissing === true && hasUnsafe(self, key)) {
881 return constInterruptedFiber()
882 }
883 const fiber = runFork(effect, options)
884 setUnsafe(self, key, fiber, options)
885 return fiber
886 }
887 }
888 )
889
890/**
891 * Captures the current runtime and returns a function for running effects in

Callers 2

makeRuntimeFunction · 0.70
runtimePromiseFunction · 0.70

Calls 4

runForkFunction · 0.85
setUnsafeFunction · 0.85
contextMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected