system_context
| Type | Class |
| Namespace | conjure::ecs |
| Include File Path | engine/include/conjure/ecs/system.h |
| Source File Path | engine/src/ecs/system.cpp |
| API ↗ | Command buffers and observers, Queries, views and systems |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | system_context(
ecs::world &target,
const frame_info &frame,
u64 sinceVersion,
u64 runVersion,
command_buffer &commands,
core::jobs::job_system *jobs,
const system_desc &desc,
system_scratch &scratch,
bool parallelChunks,
u32 minEntitiesPerJob) noexcept; | Builds a context. sinceVersion is the version observed at the start of the previous run, runVersion the version chunk views created through this context stamp. |
Important
Copy constructor and assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~system_context(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mCommands | command_buffer * | nullptr | |
| private | mDesc | const system_desc * | nullptr | |
| private | mFrame | const frame_info * | nullptr | |
| private | mJobs | core::jobs::job_system * | nullptr | |
| private | m | u32 | 0 | |
| private | m | u32 | 1024 | |
| private | m | bool | true | |
| private | mRunVersion | u64 | 0 | |
| private | mScratch | system_scratch * | nullptr | |
| private | m | u64 | 0 | |
| private | mWorld | ecs::world * | nullptr |
Functions
Public
commands
commands[[nodiscard]] command_buffer &commands() noexcept;The system's command buffer, flushed when the stage ends. System thread only; jobs of parallel_for_chunks receive their own grain buffer.
jobs
jobs[[nodiscard]] core::jobs::job_system *jobs() noexcept;The job system, or nullptr when everything runs inline.
last_grain_count
last_grain_count[[nodiscard]] u32 last_grain_count() const noexcept;Number of grains the last parallel_for_chunks dispatch used (for tests and profiling).
parallel_for_chunks
parallel_for_chunkstemplate <typename Callable> void parallel_for_chunks(
query &target,
Callable &&callable);Runs callable(chunk_view &, command_buffer &) over the chunks matched by target. Chunks are grouped into grains of max(1, minEntitiesPerJob / capacity) chunks, each grain runs as one job (inline without a job system or with chunk parallelism disabled) with its own command buffer, and the grain buffers are appended to commands() in grain order after the join. The callable must not touch state shared between grains without synchronisation.
since_version
since_version[[nodiscard]] u64 since_version() const noexcept;The world version at the start of this system's previous run: a changed<T> filter against it sees every write since, but never the system's own previous writes made through view() or parallel_for_chunks (those stamp run_version()). Writes through world().get<T>(), set() or component_ref stamp the current world version, which a sibling's run or a structural call may have bumped past run_version(), so the next run can see those.
view
viewtemplate <typename... ComponentTypes> [[nodiscard]] ecs::view<ComponentTypes...> view();A typed view validated against the declared access in Debug and Development: every required or optional component must be in reads | writes and every written one in writes. Violations assert naming the system. The chunk views the result hands out carry this context, so a non-const span of an undeclared component asserts too; the view must not outlive the system run. The checks compile out in Distribution; the view is bound to this context in every configuration, so its writes stamp run_version().
world
world[[nodiscard]] ecs::world &world() noexcept;The world the system runs on.
[[nodiscard]] const ecs::world &world() const noexcept;Private
dispatch_chunks
dispatch_chunksvoid dispatch_chunks(
query &target,
void (*visit)(void *context, chunk_view &view, command_buffer &commands),
void *context);validate_access
validate_accessvoid validate_access(
const view_access &access) const;