From 5812409078db6b33047fc6267d2415411ecad4fb Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 5 Apr 2024 19:16:17 -0700 Subject: [PATCH] module: document loop intention, fix test Signed-off-by: Stephen Gutekanst --- src/module.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/module.zig b/src/module.zig index b438e92b..7d25ea7f 100644 --- a/src/module.zig +++ b/src/module.zig @@ -33,6 +33,11 @@ //! events being dispatched, showing you the execution of e.g. a frame. Or, events could be saved //! to disk and replayed/inspected later. //! * Networking between modules - events could be serialized and sent over the network. +//! * Loops executing at different frequencies - a 'loop' is simply events firing in a circular loop, +//! e.g. you could have multiple loops of events going at the same time, using an event as a +//! synchronization point: +//! * .render_begin -> wait for .physics_sync -> .game_tick -> .game_draw_frame -> .render_end -> .render_begin +//! * .physics_begin -> .poll_input -> .physics_calculate -> .physics_sync -> .physics_end -> .physics_begin //! //! ## Event arguments //! @@ -1423,7 +1428,7 @@ test "dispatch" { try modules.dispatchInternal(.{&foo}); try testing.expect(usize, 2).eql(global.ticks); // TODO: make sendDynamic take an args type to avoid footguns with comptime values, etc. - modules.sendDynamicGlobal(@intFromEnum(@as(GE, .tick)), .{}); + modules.sendGlobalDynamic(@intFromEnum(@as(GE, .tick)), .{}); try modules.dispatchInternal(.{&foo}); try testing.expect(usize, 4).eql(global.ticks);