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

Function runFork

packages/effect/src/Micro.ts:4215–4236  ·  view source on GitHub ↗
(
  effect: Micro<A, E>,
  options?: {
    readonly signal?: AbortSignal | undefined
    readonly scheduler?: MicroScheduler | undefined
  } | undefined
)

Source from the content-addressed store, hash-verified

4213 * @category execution
4214 */
4215export const runFork = <A, E>(
4216 effect: Micro<A, E>,
4217 options?: {
4218 readonly signal?: AbortSignal | undefined
4219 readonly scheduler?: MicroScheduler | undefined
4220 } | undefined
4221): MicroFiberImpl<A, E> => {
4222 const fiber = new MicroFiberImpl<A, E>(CurrentScheduler.context(
4223 options?.scheduler ?? new MicroSchedulerDefault()
4224 ))
4225 fiber.evaluate(effect as any)
4226 if (options?.signal) {
4227 if (options.signal.aborted) {
4228 fiber.unsafeInterrupt()
4229 } else {
4230 const abort = () => fiber.unsafeInterrupt()
4231 options.signal.addEventListener("abort", abort, { once: true })
4232 fiber.addObserver(() => options.signal!.removeEventListener("abort", abort))
4233 }
4234 }
4235 return fiber
4236}
4237
4238/**
4239 * Execute the `Micro` effect and return a `Promise` that resolves with the

Callers 15

runtimeFunction · 0.70
runtimePromiseFunction · 0.70
runtimeFunction · 0.70
runtimePromiseFunction · 0.70
runPromiseExitFunction · 0.70
runSyncExitFunction · 0.70
runtimeFunction · 0.70
runtimePromiseFunction · 0.70
onMessageFunction · 0.50
asyncPauseResumeFunction · 0.50
startFunction · 0.50
makeHandlerFunction · 0.50

Calls 6

evaluateMethod · 0.95
unsafeInterruptMethod · 0.95
addObserverMethod · 0.95
removeEventListenerMethod · 0.80
contextMethod · 0.65
addEventListenerMethod · 0.65

Tested by

no test coverage detected