Commit Graph

4 Commits

Author SHA1 Message Date
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
aa3c35bd2f docs: Update all documentation to reflect development stage
COMPREHENSIVE DOCUMENTATION CLEANUP:

DEVELOPER_GUIDE.md:
- Add prominent warning at top (development-ready, NOT production-ready)
- New 'Current Limitations' section with detailed warnings:
  * Non-deterministic execution
  * Single-threaded only
  * Not suitable for networked games
  * No error recovery, limited optimizations
- Change all 'Production Ready' → 'Development Ready' status tags
- BgfxRenderer: Phase 8 complete | Experimental
- UIModule: Phase 7 complete | Experimental
- InputModule: Phase 1-3 complete | Gamepad Phase 2 TODO
- Add 'What GroveEngine IS Good For' section (prototyping, learning, AI-assisted dev)
- Add Production Roadmap section

USER_GUIDE.md:
- Add experimental/development warning with link to README

Module READMEs:
- BgfxRenderer/README.md: Add development stage warning
- InputModule/README.md: Clarify Phase 1-3 complete, gamepad TODO
- UIModule/README.md: Add experimental warning, clarify thread-safe design is for future

All documentation now consistently reflects that GroveEngine is:
 Excellent for rapid prototyping and experimentation
⚠️ NOT ready for production games
⚠️ Non-deterministic execution
⚠️ Single-threaded only (for now)

Total changes: 5 files, 62 insertions, 13 deletions
2026-01-15 09:26:23 +07:00
5127dd5bf2 Migration Gitea 2025-12-04 20:15:53 +08:00
21590418f1 feat: Add InputModule Phase 1 + IT_015 integration tests
Complete implementation of InputModule with SDL2 backend for mouse and keyboard input, plus UIModule integration tests.

## InputModule Features
- Mouse input capture (position, buttons, wheel)
- Keyboard input capture (keys, modifiers)
- SDL2 backend implementation
- IIO topic publishing (input🐭*, input⌨️*)
- Hot-reload compatible module structure

## Integration Tests (IT_015)
- IT_015_input_ui_integration: Full UIModule + IIO input test
- IT_015_minimal: Minimal IIO-only message publishing test
- Visual test_30: InputModule interactive showcase

## Known Issues
- Tests compile successfully but cannot run due to MinGW/Windows runtime DLL initialization error (0xC0000139)
- Workaround: Use VSCode debugger or native Windows execution
- See tests/integration/IT_015_STATUS.md for details

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 17:17:37 +08:00