Retoor software development Projects Research SearchXNG
Register Sign In

22 lines
502 B
Plaintext
Raw Normal View History

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.
2015-08-31 07:15:37 +02:00
import "timer" for Timer
var a = Fiber.new {
IO.print("a before")
Timer.sleep(10)
IO.print("a after")
}
var b = Fiber.new {
IO.print("b before")
a.call()
IO.print("b after")
}
// All fibers are suspended since they were directly called and not scheduled.
IO.print("before") // expect: before
b.call() // expect: b before
// expect: a before
// expect: a after
// expect: b after
IO.print("done") // expect: done
Reference in New Issue Copy Permalink
f12581a674
wren/test/timer/sleep_called_fibers.wren
Response time: 138ms
Mail Licenses API