Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::app::SubApp Class Reference

A sub-application with its own ECS world, systems, and resources. More...

#include <sub_app.hpp>

Public Types

using ExtractFn = std::function< void(const ecs::World &, ecs::World &)>
 

Public Member Functions

 SubApp ()=default
 
 SubApp (const SubApp &)=delete
 
 SubApp (SubApp &&other) noexcept
 
 ~SubApp ()=default
 
SubAppoperator= (const SubApp &)=delete
 
SubAppoperator= (SubApp &&other) noexcept
 
void Clear ()
 Clears the sub-app, removing all data.
 
void Update (async::Executor &executor)
 Updates this sub-app by executing all scheduled systems.
 
void Extract (const ecs::World &main_world)
 Extracts data from the main world into this sub-app.
 
void BuildScheduler ()
 Builds execution graphs for all schedules.
 
template<ScheduleTrait S>
void ExecuteSchedule (async::Executor &executor, S schedule={})
 Executes a specific schedule.
 
template<StageTrait S>
void ExecuteStage (async::Executor &executor)
 Executes all schedules in a specific stage.
 
template<ecs::SystemTrait T, ScheduleTrait S>
void AddSystem (S schedule={})
 Adds a system to the specified schedule in the sub-app.
 
template<ecs::SystemTrait... Systems, ScheduleTrait S>
requires (sizeof...(Systems) > 1 && utils::UniqueTypes<Systems...>)
void AddSystems (S schedule={})
 Adds multiple systems to the specified schedule in the sub-app.
 
template<ecs::SystemTrait... Systems, ScheduleTrait S>
requires (sizeof...(Systems) > 0 && utils::UniqueTypes<Systems...>)
auto AddSystemsBuilder (S schedule={}) -> SystemConfig< S, Systems... >
 
template<ecs::SystemTrait T, ScheduleTrait S>
auto AddSystemBuilder (S schedule={}) -> SystemConfig< S, T >
 Adds a single system with fluent configuration builder.
 
template<SystemSetTrait Set, ScheduleTrait S>
auto ConfigureSet (S schedule={}) -> SystemSetConfig< S, Set >
 
template<ecs::ResourceTrait T>
void InsertResource (T &&resource)
 Inserts a resource into the sub-app's world.
 
template<ecs::ResourceTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void EmplaceResource (Args &&... args)
 Emplaces a resource into the sub-app's world.
 
template<ecs::EventTrait T>
void AddEvent ()
 Registers an event type for use in this sub-app.
 
template<ecs::EventTrait... Events>
requires (sizeof...(Events) > 1)
void AddEvents ()
 Registers multiple event types for use in this sub-app.
 
void SetExtractFunction (ExtractFn extract_fn) noexcept
 Sets custom extraction function for this sub-app.
 
void SetAllowOverlappingUpdates (bool allow) noexcept
 Sets whether this sub-app allows overlapping updates.
 
void SetMaxOverlappingUpdates (size_t max) noexcept
 Sets the maximum number of overlapping updates.
 
template<ecs::SystemTrait T>
bool ContainsSystem () const noexcept
 Checks if a system of type T is in any schedule.
 
template<ecs::SystemTrait T, ScheduleTrait S>
bool ContainsSystem (S schedule={}) const noexcept
 Checks if a system of type T is in the specified schedule.
 
template<ecs::ResourceTrait T>
bool HasResource () const noexcept
 Checks if a resource of type T exists in this sub-app.
 
template<ecs::EventTrait T>
bool HasEvent () const noexcept
 Checks if an event type is registered in this sub-app.
 
bool IsUpdating () const noexcept
 Checks if the sub-app is currently updating.
 
bool AllowsOverlappingUpdates () const noexcept
 Checks if this sub-app allows overlapping updates.
 
size_t SystemCount () const noexcept
 Gets the total number of systems across all schedules.
 
template<ScheduleTrait S>
size_t SystemCount (S schedule={}) const noexcept
 Gets the number of systems in the specified schedule of this sub-app.
 
const ecs::WorldGetWorld () const noexcept
 Gets const reference to this sub-app's world.
 

Friends

class App
 
template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
class SystemConfig
 
template<ScheduleTrait Schedule, SystemSetTrait Set>
class SystemSetConfig
 

Detailed Description

A sub-application with its own ECS world, systems, and resources.

SubApp encapsulates an ECS world and manages its own systems and resources. It allows for modular separation of functionality within an application, such as having distinct simulation and rendering sub-apps. Each SubApp can have its own execution schedules and can extract data from a main world if needed.

SubApps can be added to the main App instance and can be updated independently. They support adding modules that can register their own systems and resources.

Note
Not thread-safe. Use AllowOverlappingUpdates() trait for controlled concurrent access.

Definition at line 167 of file sub_app.hpp.

Member Typedef Documentation

◆ ExtractFn

Constructor & Destructor Documentation

◆ SubApp() [1/3]

◆ SubApp() [2/3]

helios::app::SubApp::SubApp ( const SubApp )
delete

◆ SubApp() [3/3]

helios::app::SubApp::SubApp ( SubApp &&  other)
inlinenoexcept

Definition at line 487 of file sub_app.hpp.

488 : world_(std::move(other.world_)),
489 scheduler_(std::move(other.scheduler_)),
490 extract_fn_(std::move(other.extract_fn_)),
491 is_updating_(other.is_updating_.load(std::memory_order_acquire)),
492 graphs_built_(other.graphs_built_),
493 allow_overlapping_updates_(other.allow_overlapping_updates_),
494 max_overlapping_updates_(other.max_overlapping_updates_),
495 current_overlapping_updates_(other.current_overlapping_updates_.load(std::memory_order_acquire)) {}

◆ ~SubApp()

Member Function Documentation

◆ AddEvent()

template<ecs::EventTrait T>
void helios::app::SubApp::AddEvent ( )
inline

Registers an event type for use in this sub-app.

Events must be registered before they can be written or read.

Warning
Triggers assertion if sub app is updating.
Template Parameters
TEvent type
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 337 of file sub_app.hpp.

337 {
338 world_.AddEvent<T>();
339 }
void AddEvent()
Registers an event type for use.
Definition world.hpp:967

◆ AddEvents()

template<ecs::EventTrait... Events>
requires (sizeof...(Events) > 1)
void helios::app::SubApp::AddEvents ( )
inline

Registers multiple event types for use in this sub-app.

Warning
Triggers assertion if sub app is updating.
Template Parameters
EventsEvent types to register
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 348 of file sub_app.hpp.

348 {
349 world_.AddEvents<Events...>();
350 }
void AddEvents()
Registers multiple event types for use.
Definition world.hpp:451

◆ AddSystem()

template<ecs::SystemTrait T, ScheduleTrait S>
void helios::app::SubApp::AddSystem ( schedule = {})
inline

Adds a system to the specified schedule in the sub-app.

Warning
Triggers assertion if sub app is updating.
Template Parameters
TSystem type
SSchedule type
Parameters
scheduleSchedule to add system to
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 595 of file sub_app.hpp.

595 {
596 HELIOS_ASSERT(!IsUpdating(), "Failed to add system '{}': Cannot add systems while app is running!",
598
599 if (ContainsSystem<T>(schedule)) [[unlikely]] {
600 HELIOS_WARN("System '{}' is already exist in app schedule '{}'!", ecs::SystemNameOf<T>(), ScheduleNameOf<S>());
601 return;
602 }
603
604 scheduler_.AddSystem<T>(schedule);
605 graphs_built_ = false;
606}
#define HELIOS_ASSERT(condition,...)
Assertion macro that aborts execution in debug builds.
Definition assert.hpp:140
bool IsUpdating() const noexcept
Checks if the sub-app is currently updating.
Definition sub_app.hpp:420
void AddSystem(S schedule={})
Adds a system to the specified schedule.
#define HELIOS_WARN(...)
Definition logger.hpp:687
BasicQuery< World, Allocator, Components... > Query
Type alias for query with mutable world access.
Definition query.hpp:2481

◆ AddSystemBuilder()

template<ecs::SystemTrait T, ScheduleTrait S>
auto helios::app::SubApp::AddSystemBuilder ( schedule = {}) -> SystemConfig<S, T>
inline

Adds a single system with fluent configuration builder.

Returns a builder that allows chaining configuration methods.

Warning
Triggers assertion if sub app is updating.
Template Parameters
TSystem type to add
SSchedule type
Parameters
scheduleSchedule to add system to
Returns
SystemConfig builder for fluent configuration
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 625 of file sub_app.hpp.

625 {
626 HELIOS_ASSERT(!IsUpdating(), "Failed to add system '{}': Cannot add systems while app is running!",
628 return SystemConfig<S, T>(*this, schedule);
629}

◆ AddSystems()

template<ecs::SystemTrait... Systems, ScheduleTrait S>
requires (sizeof...(Systems) > 1 && utils::UniqueTypes<Systems...>)
void helios::app::SubApp::AddSystems ( schedule = {})
inline

Adds multiple systems to the specified schedule in the sub-app.

Warning
Triggers assertion if sub app is updating.
Template Parameters
SystemsSystem types
SSchedule type
Parameters
scheduleSchedule to add systems to
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 610 of file sub_app.hpp.

610 {
611 HELIOS_ASSERT(!IsUpdating(), "Failed to add systems: Cannot add systems while app is running!");
612
613 (scheduler_.AddSystem<Systems>(schedule), ...);
614 graphs_built_ = false;
615}

◆ AddSystemsBuilder()

template<ecs::SystemTrait... Systems, ScheduleTrait S>
requires (sizeof...(Systems) > 0 && utils::UniqueTypes<Systems...>)
auto helios::app::SubApp::AddSystemsBuilder ( schedule = {}) -> SystemConfig<S, Systems...>
inline
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 619 of file sub_app.hpp.

619 {
620 HELIOS_ASSERT(!IsUpdating(), "Failed to add systems: Cannot add systems while app is running!");
621 return SystemConfig<S, Systems...>(*this, schedule);
622}
friend class SystemConfig
Definition sub_app.hpp:481

◆ AllowsOverlappingUpdates()

bool helios::app::SubApp::AllowsOverlappingUpdates ( ) const
inlinenoexcept

Checks if this sub-app allows overlapping updates.

Returns
True if overlapping updates are allowed, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 426 of file sub_app.hpp.

426{ return allow_overlapping_updates_; }

◆ BuildScheduler()

void helios::app::SubApp::BuildScheduler ( )
inline

Builds execution graphs for all schedules.

Should be called after all systems are added and before first execution.

Warning
Triggers assertion if sub app is updating.
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 575 of file sub_app.hpp.

575 {
576 HELIOS_ASSERT(!IsUpdating(), "Failed to build scheduler: Cannot build while app is running!");
577
578 scheduler_.BuildAllGraphs(world_);
579 graphs_built_ = true;
580}
void BuildAllGraphs(ecs::World &world)
Builds execution graphs for all schedules.
Definition scheduler.cpp:60

◆ Clear()

void helios::app::SubApp::Clear ( )
inline

Clears the sub-app, removing all data.

Warning
Triggers assertion if sub app is updating.
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 512 of file sub_app.hpp.

512 {
513 HELIOS_ASSERT(!IsUpdating(), "Failed to clear sub app: Cannot clear while app is running!");
514
515 world_.Clear();
516 scheduler_.Clear();
517 extract_fn_ = nullptr;
518 graphs_built_ = false;
519}
void Clear()
Clears all schedules and systems.
void Clear()
Clears the world, removing all data.
Definition world.hpp:645

◆ ConfigureSet()

template<SystemSetTrait Set, ScheduleTrait S>
auto helios::app::SubApp::ConfigureSet ( schedule = {}) -> SystemSetConfig<S, Set>
inline
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 632 of file sub_app.hpp.

632 {
633 HELIOS_ASSERT(!IsUpdating(), "Failed to configure set '{}': Cannot configure sets while app is running!",
634 SystemSetNameOf<Set>());
635 return SystemSetConfig<S, Set>(*this, schedule);
636}

◆ ContainsSystem() [1/2]

template<ecs::SystemTrait T>
bool helios::app::SubApp::ContainsSystem ( ) const
inlinenoexcept

Checks if a system of type T is in any schedule.

Template Parameters
TSystem type
Returns
True if system is present, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp, and /home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 380 of file sub_app.hpp.

380 {
381 return scheduler_.ContainsSystem<T>();
382 }
bool ContainsSystem() const noexcept
Checks if a system of type T is in any schedule.

◆ ContainsSystem() [2/2]

template<ecs::SystemTrait T, ScheduleTrait S>
bool helios::app::SubApp::ContainsSystem ( schedule = {}) const
inlinenoexcept

Checks if a system of type T is in the specified schedule.

Template Parameters
TSystem type
SSchedule type
Parameters
scheduleSchedule to check
Returns
True if system is present, false otherwise

Definition at line 392 of file sub_app.hpp.

392 {}) const noexcept {
393 return scheduler_.ContainsSystem<T>(schedule);
394 }

◆ EmplaceResource()

template<ecs::ResourceTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void helios::app::SubApp::EmplaceResource ( Args &&...  args)
inline

Emplaces a resource into the sub-app's world.

Warning
Triggers assertion if sub app is updating.
Template Parameters
TResource type
ArgsConstructor argument types
Parameters
argsArguments to forward to resource constructor
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 326 of file sub_app.hpp.

326 {
327 world_.EmplaceResource<T>(std::forward<Args>(args)...);
328 }
void EmplaceResource(Args &&... args)
Emplaces a resource in-place.
Definition world.hpp:352

◆ ExecuteSchedule()

template<ScheduleTrait S>
void helios::app::SubApp::ExecuteSchedule ( async::Executor executor,
schedule = {} 
)
inline

Executes a specific schedule.

Warning
Triggers assertion if scheduler was not built.
Template Parameters
SSchedule type
Parameters
executorAsync executor for parallel execution
scheduleSchedule to execute
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 583 of file sub_app.hpp.

583 {
584 HELIOS_ASSERT(graphs_built_, "Failed to execute schedule: Scheduler must be built before update!");
585 scheduler_.ExecuteSchedule<S>(world_, executor);
586}
void ExecuteSchedule(ecs::World &world, async::Executor &executor)
Executes all systems in the specified schedule.

◆ ExecuteStage()

template<StageTrait S>
void helios::app::SubApp::ExecuteStage ( async::Executor executor)
inline

Executes all schedules in a specific stage.

Warning
Triggers assertion if scheduler was not built.
Template Parameters
SStage type (must satisfy StageTrait)
Parameters
executorAsync executor for parallel execution
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 589 of file sub_app.hpp.

589 {
590 HELIOS_ASSERT(graphs_built_, "Failed to execute stage: Scheduler must be built before update!");
591 scheduler_.ExecuteStage<S>(world_, executor);
592}
void ExecuteStage(ecs::World &world, async::Executor &executor)
Executes all schedules in the specified stage.

◆ Extract()

void helios::app::SubApp::Extract ( const ecs::World main_world)
inline

Extracts data from the main world into this sub-app.

Warning
Triggers assertion if sub app is updating.
Parameters
main_worldConst reference to the main world to extract data from
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 567 of file sub_app.hpp.

567 {
568 HELIOS_ASSERT(!IsUpdating(), "Failed to extract: Cannot extract while app is running!");
569
570 if (extract_fn_) {
571 extract_fn_(main_world, world_);
572 }
573}

◆ GetWorld()

const ecs::World & helios::app::SubApp::GetWorld ( ) const
inlinenoexcept

Gets const reference to this sub-app's world.

Returns
Const reference to the ECS world
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp, and /home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 449 of file sub_app.hpp.

449{ return world_; }

◆ HasEvent()

template<ecs::EventTrait T>
bool helios::app::SubApp::HasEvent ( ) const
inlinenoexcept

Checks if an event type is registered in this sub-app.

Template Parameters
TEvent type
Returns
True if event type is registered, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp, and /home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 412 of file sub_app.hpp.

412 {
413 return world_.HasEvent<T>();
414 }
bool HasEvent() const
Checks if a event registered.
Definition world.hpp:545

◆ HasResource()

template<ecs::ResourceTrait T>
bool helios::app::SubApp::HasResource ( ) const
inlinenoexcept

Checks if a resource of type T exists in this sub-app.

Template Parameters
TResource type
Returns
True if resource exists, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp, and /home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 402 of file sub_app.hpp.

402 {
403 return world_.HasResource<T>();
404 }
bool HasResource() const
Checks if a resource exists.
Definition world.hpp:534

◆ InsertResource()

template<ecs::ResourceTrait T>
void helios::app::SubApp::InsertResource ( T &&  resource)
inline

Inserts a resource into the sub-app's world.

Warning
Triggers assertion if sub app is updating.
Template Parameters
TResource type
Parameters
resourceResource to insert
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 313 of file sub_app.hpp.

313 {
314 world_.InsertResource(std::forward<T>(resource));
315 }
void InsertResource(T &&resource)
Inserts a resource into the world.
Definition world.hpp:327

◆ IsUpdating()

bool helios::app::SubApp::IsUpdating ( ) const
inlinenoexcept

Checks if the sub-app is currently updating.

Returns
True if update is in progress, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 420 of file sub_app.hpp.

420{ return is_updating_.load(std::memory_order_acquire); }

◆ operator=() [1/2]

SubApp & helios::app::SubApp::operator= ( const SubApp )
delete

◆ operator=() [2/2]

SubApp & helios::app::SubApp::operator= ( SubApp &&  other)
inlinenoexcept

Definition at line 497 of file sub_app.hpp.

497 {
498 if (this != &other) {
499 world_ = std::move(other.world_);
500 scheduler_ = std::move(other.scheduler_);
501 extract_fn_ = std::move(other.extract_fn_);
502 is_updating_.store(other.is_updating_.load(std::memory_order_acquire), std::memory_order_release);
503 graphs_built_ = other.graphs_built_;
504 allow_overlapping_updates_ = other.allow_overlapping_updates_;
505 max_overlapping_updates_ = other.max_overlapping_updates_;
506 current_overlapping_updates_.store(other.current_overlapping_updates_.load(std::memory_order_acquire),
507 std::memory_order_release);
508 }
509 return *this;
510}

◆ SetAllowOverlappingUpdates()

void helios::app::SubApp::SetAllowOverlappingUpdates ( bool  allow)
inlinenoexcept

Sets whether this sub-app allows overlapping updates.

Parameters
allowTrue to allow concurrent updates, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 366 of file sub_app.hpp.

366{ allow_overlapping_updates_ = allow; }

◆ SetExtractFunction()

void helios::app::SubApp::SetExtractFunction ( ExtractFn  extract_fn)
inlinenoexcept

Sets custom extraction function for this sub-app.

The extraction function is called before the sub-app's Update to copy data from the main world. This is useful for example for render sub-app that need to extract transform, mesh, and camera data from the main simulation world.

Parameters
extract_fnFunction that takes main world and sub-app world references
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 360 of file sub_app.hpp.

360{ extract_fn_ = std::move(extract_fn); }

◆ SetMaxOverlappingUpdates()

void helios::app::SubApp::SetMaxOverlappingUpdates ( size_t  max)
inlinenoexcept

Sets the maximum number of overlapping updates.

Parameters
maxMaximum number of concurrent updates (0 = unlimited)
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 372 of file sub_app.hpp.

372{ max_overlapping_updates_ = max; }

◆ SystemCount() [1/2]

size_t helios::app::SubApp::SystemCount ( ) const
inlinenoexcept

Gets the total number of systems across all schedules.

Returns
Total number of systems
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp, and /home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 432 of file sub_app.hpp.

432{ return scheduler_.SystemCount(); }
size_t SystemCount() const noexcept
Gets the total number of systems across all schedules.

◆ SystemCount() [2/2]

template<ScheduleTrait S>
size_t helios::app::SubApp::SystemCount ( schedule = {}) const
inlinenoexcept

Gets the number of systems in the specified schedule of this sub-app.

Template Parameters
SSchedule type
Parameters
scheduleSchedule to query
Returns
Number of systems in the schedule

Definition at line 441 of file sub_app.hpp.

441 {}) const noexcept {
442 return scheduler_.SystemCount(schedule);
443 }

◆ Update()

void helios::app::SubApp::Update ( async::Executor executor)
inline

Updates this sub-app by executing all scheduled systems.

This method checks the updating flag to prevent concurrent updates when overlapping updates are not allowed. SubApps with AllowOverlappingUpdates() can bypass this check.

Warning
Triggers assertion if scheduler was not built.
Parameters
executorAsync executor for parallel execution
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/sub_app.hpp.

Definition at line 521 of file sub_app.hpp.

521 {
522 HELIOS_ASSERT(graphs_built_, "Failed to update sub app: Scheduler must be built before update!");
523
524 if (!allow_overlapping_updates_) {
525 // Enforce single update at a time
526 bool expected = false;
527 if (!is_updating_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
528 HELIOS_ERROR("Failed to update sub app: Overlapping updates not allowed!");
529 return;
530 }
531 } else {
532 // Track overlapping updates if limit is set
533 if (max_overlapping_updates_ > 0) {
534 size_t current = current_overlapping_updates_.fetch_add(1, std::memory_order_acq_rel);
535 if (current >= max_overlapping_updates_) {
536 current_overlapping_updates_.fetch_sub(1, std::memory_order_acq_rel);
537 HELIOS_WARN("Failed to update sub app: Max overlapping updates ({}) reached!", max_overlapping_updates_);
538 return;
539 }
540 }
541
542 is_updating_.store(true, std::memory_order_release);
543 }
544
545 // Execute all stages in order (StartUpStage only runs during Initialize, not Update)
546 scheduler_.ExecuteStage<MainStage>(world_, executor);
547 scheduler_.ExecuteStage<UpdateStage>(world_, executor);
548 scheduler_.ExecuteStage<CleanUpStage>(world_, executor);
549
550 // Merge all deferred commands into world after execution
551 scheduler_.MergeCommandsToWorld(world_);
552
553 // Execute all commands (create entities, add/remove components, etc.)
554 world_.Update();
555
556 // Reset all per-system frame allocators to reclaim temporary memory
557 scheduler_.ResetFrameAllocators();
558
559 // Clear update flags
560 if (allow_overlapping_updates_ && max_overlapping_updates_ > 0) {
561 current_overlapping_updates_.fetch_sub(1, std::memory_order_acq_rel);
562 }
563
564 is_updating_.store(false, std::memory_order_release);
565}
void MergeCommandsToWorld(ecs::World &world)
Merges all system local commands into the world's main command queue.
void ResetFrameAllocators() noexcept
Resets all system frame allocators.
#define HELIOS_ERROR(...)
Definition logger.hpp:689

Friends And Related Symbol Documentation

◆ App

◆ SystemConfig

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
friend class SystemConfig
friend

◆ SystemSetConfig

template<ScheduleTrait Schedule, SystemSetTrait Set>
friend class SystemSetConfig
friend