mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-14 23:58:03 +01:00
- Allow this for both argument lists and block arguments.
- Tweak precedence to make "." higher than infix "{}" to avoid a
class body being parsed as the superclass clause's block argument.
- Convert all uses of ".call" to use this. (There was not a single
case in the repo that ran into the getter ambiguity.)
28 lines
624 B
Plaintext
28 lines
624 B
Plaintext
class Scheduler {
|
|
static add(callable) {
|
|
if (__scheduled == null) __scheduled = []
|
|
|
|
__scheduled.add(Fiber.new {
|
|
callable()
|
|
@runNextScheduled_()
|
|
})
|
|
}
|
|
|
|
// Called by native code.
|
|
static resume_(fiber) { fiber.transfer() }
|
|
static resume_(fiber, arg) { fiber.transfer(arg) }
|
|
static resumeError_(fiber, error) { fiber.transferError(error) }
|
|
|
|
static runNextScheduled_() {
|
|
if (__scheduled == null || __scheduled.isEmpty) {
|
|
return Fiber.suspend()
|
|
} else {
|
|
return __scheduled.removeAt(0).transfer()
|
|
}
|
|
}
|
|
|
|
foreign static captureMethods_()
|
|
}
|
|
|
|
Scheduler.captureMethods_()
|