GroveEngine/tests/visual
StillHammer 1b7703f07b feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch
## Breaking Change

IIO API redesigned from manual pull+if-forest to callback dispatch.
All modules must update their subscribe() calls to pass handlers.

### Before (OLD API)
```cpp
io->subscribe("input:mouse");

void process(...) {
    while (io->hasMessages()) {
        auto msg = io->pullMessage();
        if (msg.topic == "input:mouse") {
            handleMouse(msg);
        } else if (msg.topic == "input:keyboard") {
            handleKeyboard(msg);
        }
    }
}
```

### After (NEW API)
```cpp
io->subscribe("input:mouse", [this](const Message& msg) {
    handleMouse(msg);
});

void process(...) {
    while (io->hasMessages()) {
        io->pullAndDispatch();  // Callbacks invoked automatically
    }
}
```

## Changes

**Core API (include/grove/IIO.h)**
- Added: `using MessageHandler = std::function<void(const Message&)>`
- Changed: `subscribe()` now requires `MessageHandler` callback parameter
- Changed: `subscribeLowFreq()` now requires `MessageHandler` callback
- Removed: `pullMessage()`
- Added: `pullAndDispatch()` - pulls and auto-dispatches to handlers

**Implementation (src/IntraIO.cpp)**
- Store callbacks in `Subscription.handler`
- `pullAndDispatch()` matches topic against ALL subscriptions (not just first)
- Fixed: Regex pattern compilation supports both wildcards (*) and regex (.*)
- Performance: ~1000 msg/s throughput (unchanged from before)

**Files Updated**
- 31 test/module files migrated to callback API (via parallel agents)
- 8 documentation files updated (DEVELOPER_GUIDE, USER_GUIDE, module READMEs)

## Bugs Fixed During Migration

1. **pullAndDispatch() early return bug**: Was only calling FIRST matching handler
   - Fix: Loop through ALL subscriptions, invoke all matching handlers

2. **Regex pattern compilation bug**: Pattern "player:.*" failed to match
   - Fix: Detect ".*" in pattern → use as regex, otherwise escape and convert wildcards

## Testing

 test_11_io_system: PASSED (IIO pub/sub, pattern matching, batching)
 test_threaded_module_system: 6/6 PASSED
 test_threaded_stress: 5/5 PASSED (50 modules, 100x reload, concurrent ops)
 test_12_datanode: PASSED
 10 TopicTree scenarios: 10/10 PASSED
 benchmark_e2e: ~1000 msg/s throughput

Total: 23+ tests passing

## Performance Impact

No performance regression from callback dispatch:
- IIO throughput: ~1000 msg/s (same as before)
- ThreadedModuleSystem: Speedup ~1.0x (barrier pattern expected)

## Migration Guide

For all modules using IIO:

1. Update subscribe() calls to include handler lambda
2. Replace pullMessage() loops with pullAndDispatch()
3. Move topic-specific logic from if-forest into callbacks

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 14:19:27 +07:00
..
README_FULL_STACK.md fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_1button_texture2.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_3buttons_minimal.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
test_23_bgfx_sprites_visual.cpp feat(BgfxRenderer): Fix multi-texture batching and add particle effects 2025-11-28 17:15:45 +08:00
test_24_ui_basic.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_25_ui_layout.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_26_ui_buttons.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
test_28_ui_scroll.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_29_ui_advanced.cpp feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
test_30_input_module.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
test_bgfx_device_only.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_bgfx_minimal_win.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_bgfx_sprites.cpp chore: Add MIT License and fix Windows platform support 2026-01-15 08:12:43 +07:00
test_bgfx_static_only.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_bgfx_triangle.cpp chore: Add MIT License and fix Windows platform support 2026-01-15 08:12:43 +07:00
test_button_with_png.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_direct_sprite_texture.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_filesystem.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_full_stack_interactive.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_full_stack_interactive.cpp.orig fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_groveengine_link.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_headers_progressive.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_iio_only.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_logger_direct.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_logger_only.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_minimal_sdl.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_progressive.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_renderer_showcase.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_sdl_groveengine.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_single_button.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
test_spdlog_filesystem.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_spdlog_only.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_spdlog_register.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_sprite_debug.cpp fix: UIModule button interaction + JsonDataNode array children support 2026-01-05 18:23:16 +07:00
test_textured_button.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_textured_demo_minimal.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_ui_showcase.cpp feat: UIModule - Dynamic text updates, documentation restructure, and IIO improvements 2026-01-14 22:34:36 +07:00
test_ui_textured_demo.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_ui_textured_simple.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_ui_textures.cpp fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00
test_use_sdl_and_iio.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_use_sdl.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
test_with_modules_include.cpp fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00