Skip to content

Engine → ECS → system.h

system_context

Syntax

class CONJURE_API system_context

Constructors

AccessSignatureDescription
publicsystem_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

AccessSignatureDescription
public~system_context();

Variables

AccessNameTypeDefaultDescription
privatemCommandscommand_buffer *nullptr
privatemDescconst system_desc *nullptr
privatemFrameconst frame_info *nullptr
privatemJobscore::jobs::job_system *nullptr
privatemLastGrainCountu320
privatemMinEntitiesPerJobu321024
privatemParallelChunksbooltrue
privatemRunVersionu640
privatemScratchsystem_scratch *nullptr
privatemSinceVersionu640
privatemWorldecs::world *nullptr

Functions

Public

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.

delta_time

[[nodiscard]] f32 delta_time() const noexcept;

frame().deltaTime.

desc

[[nodiscard]] const system_desc &desc() const noexcept;

The running system's description.

frame

[[nodiscard]] const frame_info &frame() const noexcept;

The full per-frame timing block.

jobs

[[nodiscard]] core::jobs::job_system *jobs() noexcept;

The job system, or nullptr when everything runs inline.

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

template <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.

run_version

[[nodiscard]] u64 run_version() const noexcept;

The version this run stamps.

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

template <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

[[nodiscard]] ecs::world &world() noexcept;

The world the system runs on.

[[nodiscard]] const ecs::world &world() const noexcept;

Private

dispatch_chunks

void dispatch_chunks(
    query &target,
    void (*visit)(void *context, chunk_view &view, command_buffer &commands),
    void *context);

validate_access

void validate_access(
    const view_access &access) const;