MCPcopy
hub / github.com/Effect-TS/effect / unsafeFork

Function unsafeFork

packages/effect/src/Micro.ts:4114–4131  ·  view source on GitHub ↗
(
  parent: MicroFiberImpl<FA, FE>,
  effect: Micro<A, E, R>,
  immediate = false,
  daemon = false
)

Source from the content-addressed store, hash-verified

4112 })
4113
4114const unsafeFork = <FA, FE, A, E, R>(
4115 parent: MicroFiberImpl<FA, FE>,
4116 effect: Micro<A, E, R>,
4117 immediate = false,
4118 daemon = false
4119): MicroFiber<A, E> => {
4120 const child = new MicroFiberImpl<A, E>(parent.context, parent.interruptible)
4121 if (!daemon) {
4122 parent.children().add(child)
4123 child.addObserver(() => parent.children().delete(child))
4124 }
4125 if (immediate) {
4126 child.evaluate(effect as any)
4127 } else {
4128 parent.getRef(CurrentScheduler).scheduleTask(() => child.evaluate(effect as any), 0)
4129 }
4130 return child
4131}
4132
4133/**
4134 * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or

Callers 5

raceAllFunction · 0.70
raceAllFirstFunction · 0.70
pumpFunction · 0.70
forkFunction · 0.70
forkDaemonFunction · 0.70

Calls 6

addObserverMethod · 0.95
evaluateMethod · 0.95
getRefMethod · 0.80
addMethod · 0.65
scheduleTaskMethod · 0.65
childrenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…