GroveEngine/include/grove
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
..
platform fix: Resolve bgfx Frame 1 crash on Windows DLL + MinGW GCC 15 compatibility 2025-12-30 11:03:06 +07:00
ASerializable.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
DataTreeFactory.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
DebugEngine.h feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
EngineFactory.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ICoordinationModule.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IDataNode.h feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
IDataTree.h feat: Add read-only API for concurrent DataNode access & restore test_13 cross-system tests 2025-11-20 14:02:06 +08:00
IDataValue.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IEngine.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IIO.h feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
ImGuiUI.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IModule.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
IModuleSystem.h feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
IntraIO.h feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
IntraIOManager.h fix: Resolve deadlock in IntraIOManager + cleanup SEGFAULTs 2025-11-23 11:36:33 +08:00
IOFactory.h feat: Complete migration from json to IDataNode API 2025-10-30 07:17:06 +08:00
IRegion.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ISerializable.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ITaskScheduler.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IUI_Enums.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
IUI.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
JsonDataNode.h feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips 2025-11-29 07:13:13 +08:00
JsonDataTree.h feat: Add read-only API for concurrent DataNode access & restore test_13 cross-system tests 2025-11-20 14:02:06 +08:00
JsonDataValue.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ModuleFactory.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ModuleLoader.h feat: Windows portage + Phase 4 SceneCollector integration 2025-11-27 09:48:14 +08:00
ModuleSystemFactory.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
RandomGenerator.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
Resource.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ResourceRegistry.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
SequentialModuleSystem.h feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
SerializationRegistry.h feat: Implement complete IDataNode/IDataTree system with JSON backend 2025-10-28 15:36:25 +08:00
ThreadedModuleSystem.h fix: Critical race conditions in ThreadedModuleSystem and logger 2026-01-19 07:37:31 +07:00