Maximizing Multithreading Use of Entt #1324
|
Hello~ I'm considering maximizing parallelism for entities. Based on documentation and some scattered answers, I'm treating each type of component as a container, and each entity as a container as well. I've defined five operations: EntityQuery, EntityCreator, EntityDestroyer, ComponentReader, and ComponentWriter. EntityQuery can only determine if an entity is valid or return a const view. EntityCreator can additionally create entities and return a non-const view. EntityDestroyer, in addition to these two, can also destroy entities. ComponentReader and ComponentWriter are similar. The conflict judgment logic code is as follows: The tag records the component's However, I consulted Google AI, and they said this would cause a conflict: "Although Risk: If thread A calls His meaning is that different components or entities in the entity do indeed use different pools, but the initial creation of the pools requires access to a unified object in the registry, which may cause data races in a multi-threaded environment. Is that correct? |
Replies: 1 comment
The entity pool exists from the beginning. Component pools are lazily created on first use. So, yeah, that's kinda correct. |
The entity pool exists from the beginning. Component pools are lazily created on first use. So, yeah, that's kinda correct.
You can have a dry non-multi-threaded run on the first tick(s) to populate a registry, or just use
registry.storage<T>()to force pool creation before entering the multithreaded code.