Skip to content

Commit

Permalink
feat: more parallel execution options (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored May 31, 2024
1 parent 2f27be4 commit 675c334
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
17 changes: 17 additions & 0 deletions ecsact/runtime/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,23 @@ typedef enum {
ECSACT_SYS_NOTIFY_ONREMOVE,
} ecsact_system_notify_setting;

typedef enum ecsact_parallel_execution {
/**
* Let implementation decide parallel execution.
*/
ECSACT_PAR_EXEC_AUTO = 0,

/**
* Hint to implementation that parallel execution is preferred.
*/
ECSACT_PAR_EXEC_PREFERRED = 1,

/**
* Disallow implementation to use parallel execution.
*/
ECSACT_PAR_EXEC_DENY = 2,
} ecsact_parallel_execution;

/**
* Flags for generates component set
*/
Expand Down
8 changes: 4 additions & 4 deletions ecsact/runtime/dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,13 @@ ECSACT_DYNAMIC_API_FN(void, ecsact_set_entity_execution_status)
);

/**
* Set a _hint_ that the system may process entities in parallel. This is
* only a _hint_. The runtime implementation may choose to not run in parallel.
* Sets the systems parallel execution setting.
* @SEE: ecsact_parallel_execution
*/
ECSACT_DYNAMIC_API_FN(void, ecsact_set_system_parallel_execution)
( //
ecsact_system_like_id system_like_id,
bool parallel_execution
ecsact_system_like_id system_like_id,
ecsact_parallel_execution parallel_execution
);

/**
Expand Down
5 changes: 4 additions & 1 deletion ecsact/runtime/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ ECSACT_META_API_FN(int32_t, ecsact_meta_get_lazy_iteration_rate)
* Check if a system/action can run on multiple entities in parallel. This is
* only a _hint_. The runtime implementation may choose to not run in parallel.
*/
ECSACT_META_API_FN(bool, ecsact_meta_get_system_parallel_execution)
ECSACT_META_API_FN(
ecsact_parallel_execution,
ecsact_meta_get_system_parallel_execution
)
( //
ecsact_system_like_id system_like_id
);
Expand Down
9 changes: 9 additions & 0 deletions ecsact/runtime/meta.hh
Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,13 @@ ECSACT_ALWAYS_INLINE auto main_package() -> std::optional<ecsact_package_id> {
return main_pkg_id;
}

template<typename SystemLikeID>
ECSACT_ALWAYS_INLINE auto get_system_parallel_execution( //
SystemLikeID id
) -> ecsact_parallel_execution {
return ecsact_meta_get_system_parallel_execution(
ecsact_id_cast<ecsact_system_like_id>(id)
);
}

} // namespace ecsact::meta

0 comments on commit 675c334

Please # to comment.