feat: replace fiber run() with transfer() and suspend() for scheduler-friendly semantics

Remove the run() method from fibers and introduce transfer() for non-stack-based fiber switching, along with suspend() to pause the interpreter and return control to the host application. Update Timer.sleep() to use runNextScheduled_() instead of Fiber.yield(), and add Timer.schedule() for creating independently scheduled fibers. Refactor the core fiber runtime to support transfer semantics, including proper error handling for aborted fibers and self-transfer edge cases. Fix a missing quote in test.py's runtime error validation string.
This commit is contained in:
Bob Nystrom
2015-08-31 05:15:37 +00:00
parent ca8e97521a
commit 7e111d19da
49 changed files with 469 additions and 350 deletions
+4 -4
View File
@@ -1,15 +1,15 @@
import "timer" for Timer
// These are both rounded to 1, so "a" should complete first.
Fiber.new {
Timer.schedule {
Timer.sleep(1.5)
IO.print("a")
}.call()
}
Fiber.new {
Timer.schedule {
Timer.sleep(1.3)
IO.print("b")
}.call()
}
IO.print("main")
Timer.sleep(3)