Skip to content

Commit c6680f1

Browse files
committed
feat: respect parallel system parameter
feat: new parallel value meaning
1 parent 4cdd656 commit c6680f1

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

rt_entt_codegen/shared/parallel.cc

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,25 @@ auto ecsact::rt_entt_codegen::parallel::can_entities_parallel(
178178
return true;
179179
}
180180

181+
/**
182+
* Quick check to see if a system should run independently regardless of it's
183+
* system capbilities.
184+
*/
185+
static auto should_run_independently(ecsact_system_like_id id) -> bool {
186+
// User has explicitly marked a system as not parallel; respect that.
187+
if(ecsact_meta_get_system_parallel_execution(id) == ECSACT_PARA_EXEC_DENY) {
188+
return true;
189+
}
190+
191+
// Generator systems increase storage so they may not run in parallel with
192+
// other systems.
193+
if(!ecsact::meta::get_system_generates_ids(id).empty()) {
194+
return true;
195+
}
196+
197+
return false;
198+
}
199+
181200
static auto loop_iterator(
182201
const std::vector<system_like_id_variant>& system_list,
183202
const std::vector<system_like_id_variant>::iterator begin,
@@ -190,10 +209,8 @@ static auto loop_iterator(
190209

191210
for(auto iterator = begin; iterator != system_list.end(); iterator++) {
192211
auto sys_like_id = *iterator;
193-
auto capabilities = ecsact::meta::system_capabilities(sys_like_id);
194-
auto generate_ids = ecsact::meta::get_system_generates_ids(sys_like_id);
195212

196-
if(!generate_ids.empty()) {
213+
if(should_run_independently(sys_like_id)) {
197214
if(!parallel_system_list.empty()) {
198215
parallel_system_cluster.push_back(parallel_system_list);
199216
}
@@ -209,8 +226,8 @@ static auto loop_iterator(
209226
return;
210227
}
211228

212-
std::set<ecsact_component_like_id> child_unsafe_comps{};
213-
229+
auto capabilities = ecsact::meta::system_capabilities(sys_like_id);
230+
auto child_unsafe_comps = std::set<ecsact_component_like_id>{};
214231
auto child_systems = ecsact::meta::get_child_system_ids(sys_like_id);
215232

216233
for(auto child_sys_id : child_systems) {

0 commit comments

Comments
 (0)