Skip to content

Commit 9c53fa7

Browse files
committed
chore: working needs cleanup
1 parent 7bdb89d commit 9c53fa7

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

rt_entt_codegen/shared/parallel.cc

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "ecsact/lang-support/lang-cc.hh"
66
#include "ecsact/cpp_codegen_plugin_util.hh"
77

8+
#include <iostream>
9+
810
struct loop_iterator_fields {
911
std::vector<ecsact_system_like_id>& system_list;
1012
const std::vector<ecsact_system_like_id>::iterator begin;
@@ -147,8 +149,49 @@ auto loop_iterator(
147149
return;
148150
}
149151

152+
std::set<ecsact_component_like_id> child_unsafe_comps{};
153+
154+
auto child_systems = ecsact::meta::get_child_system_ids(sys_like_id);
155+
156+
for(auto child_sys_id : child_systems) {
157+
auto cpp_system_name = decl_full_name(child_sys_id);
158+
auto child_capabilities = ecsact::meta::system_capabilities(child_sys_id);
159+
for(auto const [child_comp_id, child_capability] : child_capabilities) {
160+
if(unsafe_comps.contains(child_comp_id)) {
161+
if(child_capability == ECSACT_SYS_CAP_READONLY ||
162+
child_capability == ECSACT_SYS_CAP_OPTIONAL_READONLY) {
163+
parallel_system_cluster.push_back(parallel_system_list);
164+
loop_iterator(system_list, iterator, parallel_system_cluster);
165+
return;
166+
}
167+
}
168+
169+
if(!is_capability_safe(child_capability)) {
170+
if(unsafe_comps.contains(child_comp_id)) {
171+
parallel_system_cluster.push_back(parallel_system_list);
172+
loop_iterator(system_list, iterator, parallel_system_cluster);
173+
return;
174+
} else {
175+
child_unsafe_comps.insert(child_comp_id);
176+
}
177+
// std::cout << " STUCK ON " << cpp_name << "COMPONENT IN THE "
178+
// << cpp_system_name << std::endl;
179+
}
180+
}
181+
}
182+
150183
for(const auto [comp_id, capability] : capabilities) {
151184
auto cpp_name = decl_full_name(comp_id);
185+
186+
if(unsafe_comps.contains(comp_id)) {
187+
if(capability == ECSACT_SYS_CAP_READONLY ||
188+
capability == ECSACT_SYS_CAP_OPTIONAL_READONLY) {
189+
parallel_system_cluster.push_back(parallel_system_list);
190+
loop_iterator(system_list, iterator, parallel_system_cluster);
191+
return;
192+
}
193+
}
194+
152195
if(!is_capability_safe(capability)) {
153196
if(!unsafe_comps.contains(comp_id)) {
154197
unsafe_comps.insert(comp_id);
@@ -158,6 +201,7 @@ auto loop_iterator(
158201
return;
159202
}
160203
}
204+
161205
auto other_fields =
162206
ecsact::meta::system_association_fields(sys_like_id, comp_id);
163207

@@ -168,7 +212,7 @@ auto loop_iterator(
168212
field_id
169213
);
170214

171-
for(auto [other_comp_id, other_capability] : other_capabilities) {
215+
for(const auto [other_comp_id, other_capability] : other_capabilities) {
172216
auto cpp_name = decl_full_name(other_comp_id);
173217
if(!is_capability_safe(other_capability)) {
174218
if(!unsafe_comps.contains(other_comp_id)) {
@@ -182,6 +226,13 @@ auto loop_iterator(
182226
}
183227
}
184228
}
229+
230+
for(auto unsafe_comp : child_unsafe_comps) {
231+
if(!unsafe_comps.contains(unsafe_comp)) {
232+
unsafe_comps.insert(unsafe_comp);
233+
}
234+
}
235+
185236
parallel_system_list.push_back(sys_like_id);
186237
}
187238
parallel_system_cluster.push_back(parallel_system_list);

test/parallel/parallel_test.ecsact

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,11 @@ system ReadParallelBB {
6363
readonly ParallelB;
6464
}
6565

66+
system ParentSharedComponent {
67+
readwrite ParallelA;
68+
system ChildSharedComponent {
69+
readwrite ParallelA;
70+
}
71+
}
72+
6673

0 commit comments

Comments
 (0)