EntropyCanvas::SimulationCommandQueue
EntropyCanvas::SimulationCommandQueue
Section titled “EntropyCanvas::SimulationCommandQueue”Thread-safe command queue for external systems to submit mutations to the ECS. More…
#include <SimulationCommandQueue.h>
Public Types
Section titled “Public Types”| Name | |
|---|---|
| using std::function< void(SceneService &)> | Command |
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| void | processAll(SceneService & scene) Called at start of tick - drains and executes all queued commands. |
| size_t | pendingCount() const Check if there are pending commands (for diagnostics). |
| void | enqueue(Command cmd) Thread-safe: Enqueue a command to run during next tick. |
Detailed Description
Section titled “Detailed Description”class EntropyCanvas::SimulationCommandQueue;Thread-safe command queue for external systems to submit mutations to the ECS.
External services (network, input, etc.) can enqueue commands from any thread. Commands are drained and executed at the start of each simulation tick, ensuring all ECS mutations happen on the simulation thread.
Uses double-buffering to minimize lock contention during processing.
Public Types Documentation
Section titled “Public Types Documentation”using Command
Section titled “using Command”using EntropyCanvas::SimulationCommandQueue::Command = std::function<void(SceneService&)>;Public Functions Documentation
Section titled “Public Functions Documentation”function processAll
Section titled “function processAll”void processAll( SceneService & scene)Called at start of tick - drains and executes all queued commands.
Parameters:
- scene The SceneService to pass to each command
Must only be called from the simulation thread.
function pendingCount
Section titled “function pendingCount”size_t pendingCount() constCheck if there are pending commands (for diagnostics).
Return: Number of commands waiting to be processed
function enqueue
Section titled “function enqueue”void enqueue( Command cmd)Thread-safe: Enqueue a command to run during next tick.
Parameters:
- cmd Lambda or callable that receives SceneService reference
Can be called from any thread (network, input, etc.)
Updated on 2026-01-26 at 17:14:35 -0500