mrbgems/hal-win-task/README.md
Windows Hardware Abstraction Layer (HAL) implementation for mruby-task.
Provides timer and interrupt support for the mruby-task cooperative scheduler on Windows platforms. Uses multimedia timer (timeSetEvent/timeKillEvent) for periodic timer ticks, and CRITICAL_SECTION for interrupt protection.
winmm.lib)MRuby::Build.new do |conf|
# ... other configuration ...
# Specify Windows HAL - automatically brings in mruby-task
conf.gem core: 'hal-win-task'
end
MRuby::Build.new do |conf|
# ... other configuration ...
# Auto-detects and selects hal-win-task on Windows platforms
conf.gem core: 'mruby-task'
end
timeSetEvent) for periodic callbacksMRB_TICK_UNIT (default: 4ms)TIME_KILL_SYNCHRONOUS flag ensures clean timer shutdowntimeBeginPeriod(1)CRITICAL_SECTION objectsEnterCriticalSection/LeaveCriticalSection used for mutual exclusionMRB_TASK_MAX_VMS concurrent mruby VM instances (default: 8)InterlockedIncrement/InterlockedDecrement) for thread safetyThe implementation dynamically enables/disables the timer based on task state:
Override these macros in your build config if needed:
conf.gem core: 'hal-win-task' do |spec|
# Custom tick interval (10ms instead of default 4ms)
spec.build.defines << 'MRB_TICK_UNIT=10'
# Custom timeslice (5 ticks instead of default 3)
spec.build.defines << 'MRB_TIMESLICE_TICK_COUNT=5'
# More concurrent VMs (16 instead of default 8)
spec.build.defines << 'MRB_TASK_MAX_VMS=16'
end
timeBeginPeriod(1)mruby-task - Core task schedulerhal-posix-task - POSIX/Unix HAL implementationmrbgems/mruby-task/README.mdThe winmm library is automatically linked by the gem specification. No additional linker configuration is needed.