Skip to content

Commit d28fe63

Browse files
committed
fix: respect parallel deny even for entity iteration
When setting an ecsact system to `parallel: false` the rt entt codegen will now only iterate through entities in sequence instead of in parallel.
1 parent 9a25053 commit d28fe63

File tree

7 files changed

+19
-3
lines changed

7 files changed

+19
-3
lines changed

rt_entt_codegen/core/print_sys_exec.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static auto print_execute_systems(
480480

481481
auto exec_system_impls = [&](bool has_system_impl) {
482482
for(auto provider : system_providers) {
483-
auto result = provider->entity_iteration(ctx, names, [&] {
483+
auto result = provider->entity_iteration(ctx, sys_like_id, names, [&] {
484484
for(const auto& provider : system_providers) {
485485
provider->pre_exec_system_impl(ctx, names);
486486
}

rt_entt_codegen/core/system_provider/basic/basic.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ auto provider::basic::system_impl(
120120

121121
auto provider::basic::entity_iteration(
122122
ecsact::codegen_plugin_context& ctx,
123+
ecsact_system_like_id sys_like_id,
123124
const ecsact::rt_entt_codegen::core::common_vars& names,
124125
std::function<void()> iter_func
125126
) -> handle_exclusive_provide {

rt_entt_codegen/core/system_provider/basic/basic.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public:
7373

7474
auto entity_iteration(
7575
ecsact::codegen_plugin_context& ctx,
76+
ecsact_system_like_id sys_like_id,
7677
const ecsact::rt_entt_codegen::core::common_vars& names,
7778
std::function<void()> iter_func
7879
) -> handle_exclusive_provide;

rt_entt_codegen/core/system_provider/parallel/parallel.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,26 @@ using namespace ecsact::rt_entt_codegen::core;
88

99
auto provider::parallel::entity_iteration(
1010
ecsact::codegen_plugin_context& ctx,
11+
ecsact_system_like_id sys_like_id,
1112
const ecsact::rt_entt_codegen::core::common_vars& names,
1213
std::function<void()> iter_func
1314
) -> handle_exclusive_provide {
1415
using ecsact::cpp_codegen_plugin_util::block;
16+
using namespace std::string_literals;
17+
using ecsact::meta::get_system_parallel_execution;
18+
19+
auto execution_tag = "std::execution::par_unseq"s;
20+
if(get_system_parallel_execution(sys_like_id) == ECSACT_PAR_EXEC_DENY) {
21+
execution_tag = "std::execution::seq"s;
22+
}
1523

1624
block(
1725
ctx,
18-
"std::for_each(std::execution::par_unseq, view.begin(), "
19-
"view.end(), [&](auto entity)",
26+
std::format(
27+
"std::for_each({}, view.begin(), "
28+
"view.end(), [&](auto entity)",
29+
execution_tag
30+
),
2031
[&] { iter_func(); }
2132
);
2233
ctx.write(");\n");

rt_entt_codegen/core/system_provider/parallel/parallel.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public:
1010

1111
auto entity_iteration(
1212
ecsact::codegen_plugin_context& ctx,
13+
ecsact_system_like_id sys_like_id,
1314
const ecsact::rt_entt_codegen::core::common_vars& names,
1415
std::function<void()> iter_func
1516
) -> handle_exclusive_provide;

rt_entt_codegen/core/system_provider/system_provider.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ auto system_provider::provide_context_init(
122122

123123
auto system_provider::entity_iteration(
124124
ecsact::codegen_plugin_context& ctx,
125+
ecsact_system_like_id sys_like_id,
125126
const ecsact::rt_entt_codegen::core::common_vars& names,
126127
std::function<void()> iter_func
127128
) -> handle_exclusive_provide {

rt_entt_codegen/core/system_provider/system_provider.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public:
9595

9696
[[nodiscard]] virtual auto entity_iteration(
9797
ecsact::codegen_plugin_context& ctx,
98+
ecsact_system_like_id sys_like_id,
9899
const ecsact::rt_entt_codegen::core::common_vars& names,
99100
std::function<void()> iter_func
100101
) -> handle_exclusive_provide;

0 commit comments

Comments
 (0)