Is basic_registry<>::view<> thread safe ? #1253
-
Hello, I'm using EnTT to represent a scene and use it across multiple threads to render the scene on multiple windows. Each thread creates its views to iterate on. I read in the docs that iterating over a set of components is permitted as long as the components are neither assigned nor removed which is my case. But is the view creation supposed to be threadsafe as well ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In case of non-const views, they can trigger the creation of the underlying pools if they do not exist yet in the registry. |
Beta Was this translation helpful? Give feedback.
In case of non-const views, they can trigger the creation of the underlying pools if they do not exist yet in the registry.
Pools are stored in a vector, so yeah, if you create non-const views from different threads using i.e. an empty registry, it's a race.
This is somehow mentioned here. The approach is the same of the standard library after all. Thread safety isn't guaranteed for non-const containers, and you're probably operating on a non-const registry here. Therefore, it's up to you to pre-create all required pools or properly guard view creation calls.