Skip to content

Conversation

@krispya
Copy link
Member

@krispya krispya commented Aug 10, 2025

In order to fully decouple the different internal domains, I wanted to explore implementing command buffers. But also this lays the groundwork for MT since workers can enqueue commands and a scheduler can execute all commands in batch, in the order they were enqueued.

Here are the initial notes:

  • Parse arguments (single trait or multiple, etc).
  • Enqueue an "Add" command for each trait.
  • Flush the command buffer immediately as it is synchronous.
  • A separate commit routine runs when the command buffer is flushed and runs commitAdd.
  • This collects all the add commands together and batch updates the stores, reducing the need to loop. (Different store strategies can be added here, for example archetypes.)
  • When stores are updated, a store update event is emitted (maybe different depending on the update?).
  • A query routine listens for this event and updates the query's cache.
  • An Added event is emitted for userland listeners.

Add command gets enqueued -> Add command gets committed -> world entity-trait tables update -> table update events emit -> queries listen to this and update synchronously -> userland add events emit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants