ActorPool
Manages a collection of worker Actors and is responsible for distributing work across them.
It handles:
- Actor creation and lifecycle
- Worker script cloning and startup
- Batch-to-actor assignment
- Message dispatch (tracked and detached)
ActorPool does not collect results or track completion; it is a low-level scheduling and dispatch component used by Bridge.
Functions
Populate
Populates the pool with worker Actors
Each actor:
- Is created
- Receives a cloned worker script
- Starts the worker script immediately
WaitForReplication
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsActorPool:WaitForReplication() → ()Waits until all workers report readiness.
This blocks until each Actor sets the ready attribute, which is
typically done by calling Kernel:Ready() inside the worker.
This is used to ensure workers are fully initialized before dispatching jobs.
DispatchAll
ActorPool:DispatchAll(message: string,--
Message name
...: any--
Arguments forwarded to all actors
) → ()Sends a message to all actors.
This is used for setup or control signals rather than work distribution.
DispatchBatched
ActorPool:DispatchBatched(message: string,--
Job name
threadCount: number,--
Total logical work items
batchSize: number,--
Items per batch
...: any--
Extra arguments forwarded to workers
) → number--
Number of actors used
Dispatches a tracked job in batches across actors.
Work is divided into contiguous ranges and assigned to actors. Each actor receives at most one message containing a contiguous segment of work and is responsible for flushing results.
Returns the number of actors that were assigned work.
DispatchBatchedDetached
ActorPool:DispatchBatchedDetached(message: string,threadCount: number,--
Total logical work items
batchSize: number,--
Items per batch
...: any--
Extra arguments forwarded to workers
) → ()Pretty much the same as ActorPool:DispatchBatched but doesn't return anything
Destroy
ActorPool:Destroy() → ()Destroys all actors