Skip to content

Interaction with worlds from multiple threads #1

Open

Description

@popcron

all allocations are created on the thread that the World instance is created from. if there is system A and B, and both are on their own threads, the easiest way to have them update is inside a while(true) statement. but then any modifications to the world needs to be submitted as an event, that then gets processed on the causal thread. or both systems exist on the main thread, but within their update callback they will use a thread from ThreadPool (so its reused 1 thread per update, or 1 thread in total, per system).

the while(true) approach will probably require some kind of sync mechanism, so that it only performs its code when there are no outstanding commands to handle.

benchmarks for how systems can scale would be good for this, to compare reusing threads to a single thread per system.

Activity

  1. changed the title [-]Using ECS through deferred events for multuthreaded cases[/-] [+]Interaction with worlds from multiple threads[/+] on May 15, 2024
  2. popcron commented on Aug 23, 2024

    @popcron
    ContributorAuthor

    atm, there are now instructions. these can be put into Operation objects and then given to a world to have it perform together all at once. many systems right now follow this approach. they create an operation, and then perform them after they finish writing instructions.

    later on for global multithreading, these operations could be performed by 1 system listening for operation submissions.

  3. popcron commented on Mar 12, 2025

    @popcron
    ContributorAuthor

    Reopened because I haven't actually tested this in practice

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions