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

Function unsafeFork

packages/effect/src/Micro.ts:4115–4132  ·  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

4113 })
4114
4115const unsafeFork = <FA, FE, A, E, R>(
4116 parent: MicroFiberImpl<FA, FE>,
4117 effect: Micro<A, E, R>,
4118 immediate = false,
4119 daemon = false
4120): MicroFiber<A, E> => {
4121 const child = new MicroFiberImpl<A, E>(parent.context, parent.interruptible)
4122 if (!daemon) {
4123 parent.children().add(child)
4124 child.addObserver(() => parent.children().delete(child))
4125 }
4126 if (immediate) {
4127 child.evaluate(effect as any)
4128 } else {
4129 parent.getRef(CurrentScheduler).scheduleTask(() => child.evaluate(effect as any), 0)
4130 }
4131 return child
4132}
4133
4134/**
4135 * 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