TaskDispatcher
The TaskDispatcher port decides how a reserved invocation runs; the scheduler decides what runs. An
invocation is one fiber: a run invocation executes a task’s phases in sequence, and an abort invocation runs its
abort handler once.
inProcess keeps the fibers in a FiberMap keyed by task ID, in the scope of the layer. Closing the layer’s scope
interrupts them all, which is pi’s close().
Since v0.0.0
InProcessOptions (interface)
Section titled “InProcessOptions (interface)”Signature
export interface InProcessOptions { /** * How many invocations may run at once; the rest wait for a free slot. Default: unlimited. An invocation that * waits for another task inside its handler (`TaskRuntime.waitForTask`) keeps its slot, so a limit smaller than the * deepest chain of such waits can stall; `Next.wait` frees the slot. */ readonly concurrency?: number}Since v0.0.0
InvocationInfo (interface)
Section titled “InvocationInfo (interface)”What the dispatcher is told about the invocation it starts.
Signature
export interface InvocationInfo { readonly taskId: TaskId /** The task definition's name. */ readonly kind: string readonly mode: "run" | "abort"}Since v0.0.0
StartedInvocation (interface)
Section titled “StartedInvocation (interface)”A started invocation, bound to that one invocation and no other.
Signature
export interface StartedInvocation { /** * Interrupt the invocation and wait until it is gone, including while it still waits for a slot and has not begun. * A later invocation of the same task is never affected. */ readonly interrupt: Effect.Effect<void>}Since v0.0.0
TaskDispatcher (class)
Section titled “TaskDispatcher (class)”Signature
declare class TaskDispatcherSince v0.0.0
TaskDispatcherShape (interface)
Section titled “TaskDispatcherShape (interface)”Signature
export interface TaskDispatcherShape { /** * Start `work` and return at once. `work` cannot fail. A task has at most one invocation; starting another for the * same task replaces it. */ readonly start: (invocation: InvocationInfo, work: Effect.Effect<void>) => Effect.Effect<StartedInvocation> /** Interrupt every invocation and wait until they are gone. */ readonly interruptAll: Effect.Effect<void>}Since v0.0.0
inProcess
Section titled “inProcess”Run invocations as fibers of the layer’s scope.
Signature
declare const inProcess: (options?: InProcessOptions) => Layer.Layer<TaskDispatcher>Since v0.0.0