Skip to main content

event Namespace

Event bus for inter-system communication within the game loop. More...

Definition

namespace helios::engine::runtime::messaging::event { ... }

Classes Index

structGameLoopEventBusGroup

Tag type for the game loop event bus index space. More...

Typedefs Index

usingGameLoopEventBus = helios::core::container::buffer::TypeIndexedDoubleBuffer< helios::core::data::TypeIndexer< GameLoopEventBusGroup > >

Double-buffered event bus for decoupled inter-system communication. More...

Description

Event bus for inter-system communication within the game loop.

Provides type-safe, double-buffered event publishing and consumption for decoupled communication between game systems.

Typedefs

GameLoopEventBus

using helios::engine::runtime::messaging::event::GameLoopEventBus = helios::core::container::buffer::TypeIndexedDoubleBuffer< helios::core::data::TypeIndexer<GameLoopEventBusGroup> >

Double-buffered event bus for decoupled inter-system communication.

GameLoopEventBus is a type alias for TypeIndexedDoubleBuffer configured with a dedicated index space for game loop events. It enables systems to publish events during their update phase, which become available for consumption after the buffer swap.

## Phase/Pass Event Model

The GameLoop uses multiple event buses to control event visibility:

  • **Pass Events:** Events written with `push()` are available to subsequent passes within the **same phase only**. They are **always cleared** at the end of the phase.
  • **Phase Events:** Events written with `phasePush()` are preserved across phase boundaries and available in subsequent phases of the same frame.

This allows fine-grained control over event propagation:

``` ┌─────────────────────────────────────────────────────────────┐ │ FRAME │ ├─────────────────────────────────────────────────────────────┤ │ PRE PHASE │ │ Pass 1: push<InputEvent>() → available in Pass 2 │ │ Pass 2: read<InputEvent>() ✓ works │ │ phasePush<SpawnReq>() → available in MAIN │ │ [Phase Commit] ← Pass events CLEARED │ │ │ │ MAIN PHASE │ │ Pass 1: read<InputEvent>() ✗ EMPTY (cleared!) │ │ read<SpawnReq>() ✓ works (phasePush) │ │ push<CollisionEvent>() → available in Pass 2 │ │ Pass 2: read<CollisionEvent>() ✓ works │ │ [Phase Commit] ← Pass events CLEARED │ │ │ │ POST PHASE │ │ Pass 1: read<CollisionEvent>() ✗ EMPTY (cleared!) │ │ read<SpawnReq>() ✓ works (phasePush) │ │ [Phase Commit] ← All events CLEARED for next frame │ └─────────────────────────────────────────────────────────────┘ ```

## Usage Example

```cpp // Define an event type struct CollisionEvent { Guid entityA; Guid entityB; vec3f contactPoint; };

// In collision detection system (Main Phase, Pass 1) // Use push() for events only needed within this phase eventBus.push<CollisionEvent>(entityA, entityB, contact);

// In damage system (Main Phase, Pass 2) - same phase, works! for (const auto& evt : eventBus.read<CollisionEvent>()) { applyDamage(evt.entityA, evt.entityB); }

// For events needed in subsequent phases, use phasePush() eventBus.phasePush<SpawnRequestEvent>(poolId, position); ```

warning

Pass events (`push()`) are **always cleared** at phase boundaries. They are NOT available in subsequent phases. Use `phasePush()` for events that must survive into subsequent phases.

See Also

helios::core::container::buffer::TypeIndexedDoubleBuffer

See Also

UpdateContext - Provides access to the event bus in systems

See Also

GameLoop - Manages event bus lifecycle and commit points

Definition at line 100 of file GameLoopEventBus.ixx.


The documentation for this namespace was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.