From bac4984496eb79b6abebaad08e109a58389f59ae Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 30 Apr 2019 18:11:24 +0200 Subject: [PATCH] updated doc (close #231) --- docs/md/entity.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/md/entity.md b/docs/md/entity.md index 1c609351b..38875993f 100644 --- a/docs/md/entity.md +++ b/docs/md/entity.md @@ -1500,6 +1500,24 @@ standard library. If it's not clear, this is a great thing. As an example, this kind of iterators can be used in combination with `std::for_each` and `std::execution::par` to parallelize the visit and therefore the update of the components returned by a view or a group, as long as the -constraints previously discussed are respected.
+constraints previously discussed are respected: + +```cpp +auto view = registry.view(); + +std::for_each(std::execution::par_unseq, view.begin(), view.end(), [&view](auto entity) { + // ... +}); +``` + This can increase the throughput considerably, even without resorting to who knows what artifacts that are difficult to maintain over time. + +Unfortunately, because of the limitations of the current revision of the +standard, the parallel `std::for_each` accepts only forward iterators. This +means that the iterators provided by the library cannot return proxy objects as +references and **must** return actual reference types instead.
+This may change in the future and the iterators will almost certainly return +both the entities and a list of references to their components sooner or later. +Multi-pass guarantee won't break in any case and the performance should even +benefit from it further.