Engine → ECS → scheduler.h
scheduler
| Type | Class |
| Namespace | conjure::ecs |
| Include File Path | engine/include/conjure/ecs/scheduler.h |
| Source File Path | engine/src/ecs/scheduler.cpp |
| API ↗ | Command buffers and observers, Queries, views and systems |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | scheduler(
ecs::world &target,
core::jobs::job_system *jobs,
scheduler_desc desc = {}); |
Important
Copy constructor and assignment has been deleted. Move constructors have been deleted. Move assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~scheduler(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mDesc | scheduler_desc | {} | |
| private | mFreeRecords | std::vector<u32> | {} | |
| private | mJobs | core::jobs::job_system * | nullptr | |
| private | m | u32 | 1 | |
| private | mPhases | std:: | {} | |
| private | m | u32 | 0 | |
| private | m | u32 | 0 | |
| private | m | const frame_info * | nullptr | |
| private | mSystems | std:: | {} | |
| private | mWorld | ecs::world * | nullptr |
Functions
Public
add_system
add_system[[nodiscard]] core::result<system_id> add_system(
system_desc desc);Adds a system; its phase's stages are rebuilt lazily. A name is unique within its phase: NAME_CONFLICT (and the system is not added) when a live system of the same phase already carries the same name. Unnamed systems (the null string_id) never conflict, and the same name may be used again in another phase or after remove_system. SYSTEM_CYCLE (and the system is not added) when its after/before edges close a cycle; unknown names in those lists, the null name always among them, are ignored with one DEBUG log each, written here and never again by later additions, finalise() or the lazy rebuilds. A resolveAccess hook is called here against the world's registry, and again by finalise(), run_phase and stages() once the registry has gained component types, so the access set of a system added before a component it names is completed when that component is registered (the pass waits while the world is locked for iteration). Owner thread.
finalise
finalise[[nodiscard]] core::result<void> finalise();Builds every phase's stages now and reports SYSTEM_CYCLE and Debug access conflicts. Resolves every system's access again first when the registry has gained component types. Optional: run_phase builds lazily; the engine calls it at startup step 18 and after every module load so configuration errors surface before the first frame instead of inside it. Owner thread, outside a running phase.
find_system
find_system[[nodiscard]] system_id find_system(
system_phase target,
core::string_id name) const noexcept;The live system of a phase registered under name (disabled ones included), which is the one an after/before edge to that name binds to. An invalid id when the phase holds no such system, for the null name (unnamed systems cannot be looked up) and for an out-of-range phase.
last_timings
last_timings[[nodiscard]] std::span<const system_timing> last_timings(
system_phase target) const noexcept;Per-system timings of the last run of a phase, in stage order.
remove_system
remove_system[[nodiscard]] core::result<void> remove_system(
system_id id);Removes a system (its pending commands are discarded). SYSTEM_NOT_FOUND for a stale id.
run_phase
run_phasevoid run_phase(
system_phase target,
const frame_info &frame);Runs every enabled system of the phase, stage by stage, flushing command buffers at each stage boundary. Owner thread, world unlocked. When the registry has gained component types since the access sets were last resolved, every resolveAccess hook runs again first and the phases whose systems gained access are rebuilt before their next run; otherwise that check is one atomic load. The per-stage bookkeeping lives in the phase (kept at capacity) and stage jobs complete on a stack-held core::jobs::job_fence, so a phase that has run once allocates nothing of its own afterwards, with parallelSystems and a job system included (tests/ecs/test_scheduler.cpp gates it at zero in both modes).
run_phase_filtered
run_phase_filteredvoid run_phase_filtered(
system_phase target,
const frame_info &frame,
system_flags required);Runs only the systems of the phase whose flags contain every bit of required.
set_enabled
set_enabled[[nodiscard]] core::result<void> set_enabled(
system_id id,
bool enabled);Enables or disables a system (DISABLED flag). SYSTEM_NOT_FOUND for a stale id.
stages
stages[[nodiscard]] std::span<const stage_info> stages(
system_phase target);The stages of a phase. A phase left dirty by add_system, remove_system or set_enabled, or by an access set that grew with the registry, is rebuilt here first, which allocates and can fail, so the method is non-const by design. Empty for an out-of-range phase or a failed rebuild. Owner thread, outside a running phase.
system
system[[nodiscard]] const system_desc *system(
system_id id) const noexcept;The description of a system; nullptr for a stale id. Its reads and writes are the access set as last resolved: they grow when finalise(), run_phase or stages() resolves it again.
Private
build_stages
build_stages[[nodiscard]] core::result<void> build_stages(
system_phase target);find_record
find_record[[nodiscard]] system_record *find_record(
system_id id) noexcept;[[nodiscard]] const system_record *find_record(
system_id id) const noexcept;mark_dirty
mark_dirtyvoid mark_dirty(
system_phase target);refresh_access
refresh_accessvoid refresh_access();resolve_edges
resolve_edgesvoid resolve_edges(
system_phase target,
std::vector<std::vector<u32>> &predecessors,
const system_record *logFor);run_system
run_systemvoid run_system(
system_record &record,
const frame_info &frame);topological_order
topological_order[[nodiscard]] core::result<std::vector<u32>> topological_order(
system_phase target,
const std::vector<std::vector<u32>> &predecessors);