diff --git a/rt_entt_codegen/shared/parallel.cc b/rt_entt_codegen/shared/parallel.cc index 477202d..3b68f4a 100644 --- a/rt_entt_codegen/shared/parallel.cc +++ b/rt_entt_codegen/shared/parallel.cc @@ -4,7 +4,6 @@ #include #include #include - #include "ecsact/lang-support/lang-cc.hh" #include "rt_entt_codegen/shared/system_variant.hh" #include "system_variant.hh" @@ -178,6 +177,25 @@ auto ecsact::rt_entt_codegen::parallel::can_entities_parallel( return true; } +/** + * Quick check to see if a system should run independently regardless of it's + * system capbilities. + */ +static auto should_run_independently(ecsact_system_like_id id) -> bool { + // User has explicitly marked a system as not parallel; respect that. + if(ecsact_meta_get_system_parallel_execution(id) == ECSACT_PAR_EXEC_DENY) { + return true; + } + + // Generator systems increase storage so they may not run in parallel with + // other systems. + if(!ecsact::meta::get_system_generates_ids(id).empty()) { + return true; + } + + return false; +} + static auto loop_iterator( const std::vector& system_list, const std::vector::iterator begin, @@ -190,10 +208,8 @@ static auto loop_iterator( for(auto iterator = begin; iterator != system_list.end(); iterator++) { auto sys_like_id = *iterator; - auto capabilities = ecsact::meta::system_capabilities(sys_like_id); - auto generate_ids = ecsact::meta::get_system_generates_ids(sys_like_id); - if(!generate_ids.empty()) { + if(should_run_independently(sys_like_id)) { if(!parallel_system_list.empty()) { parallel_system_cluster.push_back(parallel_system_list); } @@ -209,8 +225,8 @@ static auto loop_iterator( return; } - std::set child_unsafe_comps{}; - + auto capabilities = ecsact::meta::system_capabilities(sys_like_id); + auto child_unsafe_comps = std::set{}; auto child_systems = ecsact::meta::get_child_system_ids(sys_like_id); for(auto child_sys_id : child_systems) {