You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1021 B

  1. #pragma once
  2. #include <ecs/config.h>
  3. namespace ecs {
  4. namespace core {
  5. namespace system {
  6. namespace parallelism {
  7. template<typename T_parameters>
  8. struct fixed_threshold
  9. {
  10. using parameters_type = T_parameters;
  11. using strategy_lower_type = typename parameters_type::strategy_lower_type;
  12. using strategy_greater_type = typename parameters_type::strategy_greater_type;
  13. strategy_lower_type _strategy_lower;
  14. strategy_greater_type _strategy_greater;
  15. template<typename T_context, typename T_instance, typename T_func>
  16. inline void operator()(T_context& context, T_instance& instance, T_func&& func) const
  17. {
  18. bool threshold_reached = instance.subscribed_count() >= parameters_type::get_threshold();
  19. if (!threshold_reached) _strategy_lower (instance, context, std::forward<T_func>(func));
  20. else _strategy_greater(instance, context, std::forward<T_func>(func));
  21. }
  22. };
  23. } } } }