Skip to content

EntropyCanvas::SimulationCommandQueue

Thread-safe command queue for external systems to submit mutations to the ECS. More…

#include <SimulationCommandQueue.h>

Name
using std::function< void(SceneService &)>Command
Name
voidprocessAll(SceneService & scene)
Called at start of tick - drains and executes all queued commands.
size_tpendingCount() const
Check if there are pending commands (for diagnostics).
voidenqueue(Command cmd)
Thread-safe: Enqueue a command to run during next tick.
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.

using EntropyCanvas::SimulationCommandQueue::Command = std::function<void(SceneService&)>;
void processAll(
SceneService & scene
)

Called at start of tick - drains and executes all queued commands.

Parameters:

Must only be called from the simulation thread.

size_t pendingCount() const

Check if there are pending commands (for diagnostics).

Return: Number of commands waiting to be processed

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