Files
hakorune/apps/tests/taskgroup-join-demo/main.nyash
Moe Charm c9366d5c54 Phase 11.8/12: MIR Core-13 roadmap, Nyash ABI design, async/await enhancements with TaskGroupBox foundation
Major additions:
- Phase 11.8 MIR cleanup specification (Core-15→14→13 roadmap)
- Nyash ABI unified design document (3×u64 structure)
- TaskGroupBox foundation with cancelAll/joinAll methods
- Enhanced async/await with checkpoint auto-insertion
- Structured concurrency preparation (parent-child task relationships)

Documentation:
- docs/development/roadmap/phases/phase-11.8_mir_cleanup/: Complete Core-13 path
- docs/development/roadmap/phases/phase-12/NYASH-ABI-DESIGN.md: Unified ABI spec
- Updated Phase 12 README with AOT/JIT explanation for script performance
- Added async_task_system/ design docs

Implementation progress:
- FutureBox spawn tracking with weak/strong reference management
- VM checkpoint integration before/after await
- LLVM backend async support preparation
- Verifier rules for await-checkpoint enforcement
- Result<T,E> normalization for timeout/cancellation

Technical insights:
- MIR as 'atomic instructions', Box as 'molecules' philosophy
- 'Everything is Box' enables full-stack with minimal instructions
- Unified BoxCall for array/plugin/async operations future consolidation

Next steps:
- Complete TaskGroupBox implementation
- Migrate from global to scoped task management
- Implement LIFO cleanup on scope exit
- Continue Core-13 instruction consolidation

🚀 'From 15 atoms to infinite programs: The Nyash Box Theory'
2025-09-02 03:41:51 +09:00

28 lines
828 B
Plaintext

// @env NYASH_PLUGIN_ONLY=1
// @env NYASH_AWAIT_MAX_MS=500
// Demo: TaskGroupBox.joinAll() scaffold
// Note: In plugins-only mode, new TaskGroupBox() may be a no-op; this demo
// focuses on end-of-program joinAll via runner and explicit call safety.
local fut, arr
// Prepare a plugin-backed Array and spawn a method via env.future.spawn_instance
arr = new ArrayBox()
arr.push(1)
arr.push(2)
arr.push(3)
// nowait: simulate async by invoking plugin via env.future.spawn_instance
// Note: In current pipeline, MIR builder lowers nowait ... to env.future.spawn_instance
nowait fut = arr.length()
// Optionally wait with timeout (builder inserts safepoint before/after)
local r
r = await fut
// Runner will best-effort join all registered futures at program end
// Print result for visual confirmation
print("Result: " + r)