`sleep` function in driver-timer

This commit is contained in:
Tony Garnock-Jones 2018-11-05 21:17:14 +00:00
parent 6b0ba2997e
commit 6069455cb7
1 changed files with 8 additions and 0 deletions

View File

@ -23,6 +23,14 @@ export { PeriodicTick, TimeLaterThan };
message type PeriodicTick(intervalMS);
assertion type TimeLaterThan(deadlineMS);
export function sleep(ms, cb) {
react {
stop on asserted TimeLaterThan(+(new Date()) + ms) {
cb();
}
}
}
spawn named 'driver-timer/PeriodicTick' {
during Observe(PeriodicTick($intervalMS)) spawn named ('PeriodicTick('+intervalMS+')') {
let handle = null;