Files
wren/src/module/scheduler.wren
Bob Nystrom c3e2f17758 Allow infix () and {} to call "call" on the left-hand side.
- 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.)
2015-12-01 07:49:04 -08:00

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_()