Dispatcher
The public interface used to execute parallel jobs.
It provides multiple dispatch modes:
- Tracked: collect results and invoke a callback
- Detached: fire-and-forget execution with no results
And these dispatch modes may be immediate or deferred.
The Dispatcher itself is serial; parallelism is handled by the Kernel
Functions
new
Creates a new Dispatcher.
This spawns a pool of worker actors using the provided worker script and initializes the internal bridge.
Dispatch
Dispatcher:Dispatch(name: string,--
Job name
threadCount: number,--
Total logical work items
callback: function,--
(buf: { any }) -> ()
batchSize: number?,--
Optional batch size override
...: any--
Extra arguments forwarded to workers
) → ()Dispatches a tracked job.
The job:
- Is split into batches
- Executed in parallel
- Returns results into a contiguous table buffer
- Invokes the callback once all work completes
This is the standard for intensive computation jobs with no side-effects.
DispatchDeferred
Dispatcher:DispatchDeferred(name: string,--
Job name
threadCount: number,--
Total logical work items
callback: function,--
(buf: { any }) -> ()
batchSize: number?,--
Optional batch size override
...: any--
Extra arguments forwarded to workers
) → ()Deferred proxy to Dispatcher:Dispatch
DispatchDetached
Dispatcher:DispatchDetached(name: string,--
Job name
threadCount: number,--
Total logical work items
_batchSize: number?,--
Optional batch size override
...: any) → ()Dispatches a detached job.
The job:
- Is split into batches
- Executed in parallel
This is the lowest-overhead mode and is suitable for pure side-effect jobs such as raycasts, writes, or simulation steps.
DispatchDetachedDeferred
Dispatcher:DispatchDetachedDeferred(name: string,--
Job name
threadCount: number,--
Total logical work items
_batchSize: number?,--
Optional batch size override
...: any) → ()Deferred proxy to Dispatcher:DispatchDetached
Destroy
Dispatcher:Destroy() → ()