[pull] master from mruby:master#180
Merged
pull[bot] merged 7 commits intosysfce2:masterfrom Jan 20, 2026
Merged
Conversation
With this PR, I can remove the original task.c in picoruby/picoruby and future development will be much easier. ## Add ### General - C API functions exported with MRB_API for external integration: - mrb_execute_proc_synchronously() for synchronous proc execution - Task control APIs (mrb_create_task, mrb_suspend_task, mrb_resume_task, mrb_terminate_task, mrb_stop_task, mrb_task_value, mrb_task_status) - Task context management APIs for picoruby-sandbox (mrb_task_init_context, mrb_task_reset_context, mrb_task_proc_set) - Task.tick class method to get current tick count - Comprehensive C API documentation with WASM integration examples ### For PicoRuby.wasm - WASM/Emscripten support: Disable SIGALRM timer when __EMSCRIPTEN__ is defined, as JavaScript handles tick calls via setInterval - Scheduler lock mechanism to prevent asynchronous task operations during synchronous execution (scheduler_lock counter in mrb_task_state) - mrb_task_run_once() for single-step execution (event loop integration) ## Fix ### task.c - Replace MRB_FIBER_TERMINATED with MRB_TASK_STOPPED just for clarity - Allow suspending DORMANT and WAITING tasks in mrb_task_suspend (See comment in the source) - Task context initialization by removing dummy callinfo push/pop *NOTE* With the dummy callinfo code that I deleted, IRB in PicoRuby ended SEGV. If that code is mandatory, we need to discuss how to solve my problem. ### vm.c - Handle MRB_TASK_CREATED status in VM's NORMAL_RETURN phase to properly stop tasks ---- These changes are necessary to make PicoRuby work. Nevertheless, even with this patch, MicroRuby for Raspberry Pi Pico 2 is still unstable. I would like to merge this PR anyway to make development easier by involving the PicoRuby community.
And refactoring to consolidate duplicate code ref PR #6699
Wrap sync task by mrb_gc_arena_save/restore to release objects from arena that a sync task allocated so that they can be freed in GC cycle
- Fix inconsistency of MRB_API functions and Ruby methods - Get rid of duplication - Adjust error handling
- Add mrb_gc_protect() after arena_restore to prevent result from being collected before returning to caller - Add comment to suspend_task_internal explaining why WAITING and DORMANT tasks can also be suspended - Move argc/argv cast at the beginning of function with comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )