Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
executor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5namespace helios::ecs {
6
7class Schedule;
8class World;
9
10/// @brief Kind of executor to use for schedule execution.
11enum class ExecutorKind : uint8_t {
12 /// Systems run sequentially on the calling (main) thread.
13 /// Required for APIs with main-thread affinity (rendering, platform).
15 /// Systems run sequentially on a single thread.
17 /// Systems run in parallel using work-stealing.
19};
20
21/**
22 * @brief Abstract interface for schedule executors.
23 * @details Receives a compiled schedule and world, running all systems
24 * according to the execution plan. Implementations determine threading
25 * strategy.
26 */
27class Executor {
28public:
29 virtual ~Executor() = default;
30
31 /**
32 * @brief Submits all systems in the schedule for execution.
33 * @details May return before execution completes. Call Wait() to block until
34 * completion.
35 * @param schedule Compiled schedule to execute
36 * @param world World to pass to each system
37 */
38 virtual void Execute(Schedule& schedule, World& world) = 0;
39
40 /**
41 * @brief Executes all systems in the schedule and blocks until completion.
42 * @details Default implementation calls Execute() then Wait().
43 * @param schedule Compiled schedule to execute
44 * @param world World to pass to each system
45 */
46 virtual void ExecuteAndWait(Schedule& schedule, World& world);
47
48 /**
49 * @brief Blocks until the most recent Execute() completes.
50 * @details Does nothing if no execution is pending.
51 */
52 virtual void Wait() {}
53};
54
55inline void Executor::ExecuteAndWait(Schedule& schedule, World& world) {
56 Execute(schedule, world);
57 Wait();
58}
59
60} // namespace helios::ecs
Abstract interface for schedule executors.
Definition executor.hpp:27
virtual ~Executor()=default
virtual void ExecuteAndWait(Schedule &schedule, World &world)
Executes all systems in the schedule and blocks until completion.
Definition executor.hpp:55
virtual void Execute(Schedule &schedule, World &world)=0
Submits all systems in the schedule for execution.
virtual void Wait()
Blocks until the most recent Execute() completes.
Definition executor.hpp:52
A collection of systems, sets, and run conditions with ordering constraints.
Definition schedule.hpp:182
The World class manages entities with their components and systems.
Definition world.hpp:39
ExecutorKind
Kind of executor to use for schedule execution.
Definition executor.hpp:11
@ kMultiThreaded
Systems run in parallel using work-stealing.
Definition executor.hpp:18
@ kSingleThreaded
Systems run sequentially on a single thread.
Definition executor.hpp:16