remove redundant visualcpp and mingw checks since for_windows? already
detects all windows builds including visual c++ and mingw.
ref #6653
Co-authored-by: Claude <noreply@anthropic.com>
mingw provides posix compatibility for file i/o but not for signal
handling. hal-posix-task relies on SIGALRM, setitimer(), and
sigprocmask() which are not available on windows even through mingw.
changed hal selection for mruby-task to use hal-win-task for mingw,
while mruby-dir, mruby-io, and mruby-socket correctly use posix hals
for mingw since those features are supported.
Co-authored-by: Claude <noreply@anthropic.com>
when building with MSVC on Windows, RUBY_PLATFORM (from the Ruby
installation running rake) may indicate "mingw" if Ruby was installed
via RubyInstaller, causing incorrect selection of POSIX HALs instead
of Windows HALs.
fixed by checking spec.build.primary_toolchain first:
- if toolchain is "visualcpp", select Windows HALs
- otherwise fall through to existing platform checks
this ensures MSVC builds use hal-win-* gems even when Ruby itself
was installed with MinGW.
affected gems:
- mruby-dir
- mruby-io
- mruby-socket
- mruby-task
Co-authored-by: Claude <noreply@anthropic.com>
separates platform-specific timer and interrupt code into hal-posix-task
and hal-win-task gems. mruby-task now uses HAL interface defined in
task_hal.h, making it easier to port to new platforms.
hal-posix-task: uses sigalrm/setitimer for timer, sigprocmask for irq
protection, and SA_RESTART flag to prevent EINTR on system calls.
hal-win-task: uses multimedia timer API and critical_section for irq
protection.
both HALs support multiple mrb_state instances with single shared timer.
auto-detection loads appropriate HAL based on platform.
Co-authored-by: Claude <noreply@anthropic.com>
mruby-task uses mrb_context and mrb_fiber_state enum, but these are
part of core mruby, not the mruby-fiber gem. the dependency was not
needed.
Co-authored-by: Claude <noreply@anthropic.com>
windows multimedia timer api requires linking with winmm.lib. added
conditional linker library using spec.for_windows? to match mruby
build system conventions.
Co-authored-by: Claude <noreply@anthropic.com>
this patch fixes several critical issues in the task scheduler:
1. vm integration for computed goto dispatch mode:
- added task switching check in NEXT macro for computed goto
- previous implementation only worked with switch dispatch mode
- now Task.pass properly yields control to other tasks
2. task lifecycle tracking:
- added 'started' flag to mrb_task structure
- fixed first-run detection to avoid popping callinfo multiple times
- vm overwrites context status during execution, making it unreliable
3. removed mrblib/task.rb:
- empty Ruby method stubs were overriding C implementations
- all task methods now properly implemented in C
4. cleaned up task scheduler loop:
- proper task completion detection using switching flag
- round-robin scheduling for tasks at same priority
- clean scheduler exit when all tasks complete
tasks now cooperatively yield with Task.pass and complete cleanly.
Co-authored-by: Claude <noreply@anthropic.com>
create mruby-task gem directory structure with:
- mrbgem.rake: gem specification with task scheduler define
- include/task.h: tcb structure and core scheduler declarations
- src/task.c: implementation skeleton with empty method stubs
- mrblib/task.rb: ruby api documentation and task::stat class
all methods have empty bodies ready for implementation.
Co-authored-by: Claude <noreply@anthropic.com>