diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-02-12 17:07:55 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-02-12 17:07:55 -0500 |
commit | 3eccd38e989012ff35ee5376670aabc338c52008 (patch) | |
tree | e245a1db2f737feb0546c8d83e0673ca210b28df /entityx/Entity.h | |
parent | 7189e7d0d5130b7bb37c4d65e595b1608b3c39c8 (diff) |
locked EM.each, arenas
Diffstat (limited to 'entityx/Entity.h')
-rw-r--r-- | entityx/Entity.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/entityx/Entity.h b/entityx/Entity.h index 3217ae5..a423f8f 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -16,6 +16,7 @@ #include <new> #include <cstdlib> #include <algorithm> +#include <mutex> #include <bitset> #include <cassert> #include <iostream> @@ -462,8 +463,11 @@ class EntityManager : entityx::help::NonCopyable { template <typename T> struct identity { typedef T type; }; void each(typename identity<std::function<void(Entity entity, Components&...)>>::type f) { + static std::mutex locked; + locked.lock(); for (auto it : *this) f(it, *(it.template component<Components>().get())...); + locked.unlock(); } private: |