feat: add scheduler module and refactor built-in module loading into shared modules.c
Introduce a new scheduler module with fiber-based cooperative multitasking, including native bindings for resume operations and a Wren class for scheduling callables. Refactor the existing timer module and CLI code to use a centralized built-in module registry in modules.c, replacing direct includes of timer.h and timer.wren.inc. Update Xcode project and Makefile to compile the new scheduler.c, modules.c, and their generated .wren.inc sources.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import "scheduler" for Scheduler
|
||||
import "timer" for Timer
|
||||
|
||||
var run = false
|
||||
Scheduler.add {
|
||||
run = true
|
||||
}
|
||||
|
||||
// Does not run immediately.
|
||||
IO.print(run) // expect: false
|
||||
|
||||
Timer.sleep(0)
|
||||
|
||||
// Runs when the main fiber suspends on IO.
|
||||
IO.print(run) // expect: true
|
||||
Reference in New Issue
Block a user