|
- #pragma once
-
- #include <ecs/config.h>
- #include <ecs/core/system/data_proxy.h>
-
- namespace ecs {
- namespace core {
- namespace system {
- namespace parallelism {
-
- struct none
- {
- public:
- template<typename T_context, typename T_instance>
- struct executor_proxy
- {
- public:
- using context_type = T_context;
- using instance_type = T_instance;
-
- context_type& context;
- instance_type& instance;
-
- public:
- template<typename T_func>
- inline void for_subtasks(T_func&& func)
- {
- instance.prepare_states(1);
- auto data = data_proxy::make_single(context, instance);
- std::forward<T_func>(func)(data);
- }
- };
-
- private:
- #ifndef NDEBUG
- bool _bound { false };
- mutable std::thread::id _thread_id { 0 };
- #endif
-
- public:
- #ifndef NDEBUG
- none(bool bound)
- : _bound(bound)
- { }
- #else
- none()
- { }
- #endif
-
- template<typename T_context, typename T_instance, typename T_func>
- inline void operator()(T_context& context, T_instance& instance, T_func&& func) const
- {
- #ifndef NDEBUG
- assert( !_bound
- && ( _thread_id == std::thread::id { 0 }
- || _thread_id == std::this_thread::get_id()));
- _thread_id = std::this_thread::get_id();
- #endif
-
- executor_proxy<T_context, T_instance> ep { context, instance };
- std::forward<T_func>(func)(instance, ep);
- }
- };
-
- } } } }
|