diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-12-24 17:05:13 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-12-24 17:05:13 +0000 |
commit | e1ec1faff78edbb3158fa609c61622929f7b3e68 (patch) | |
tree | 01985742344570fc58a2b65d3e7f353cc4dad667 | |
parent | Maintain the availability records (diff) | |
download | toy-e1ec1faff78edbb3158fa609c61622929f7b3e68.zip |
Process events in order without cache
-rw-r--r-- | scripts/toy.groovy | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 3d8b064..f5182aa 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -207,17 +207,13 @@ def removeEvent = { name -> saveEvents(events); }; def execEvents = { rt -> - def events = loadEvents(); - events - .findAll({ e -> e.value.time <= getTime() }) - .each({ e -> - def f = namedEvents[e.value.func]; - events.remove(e.key); - saveEvents(events); - if (f) { - f(e.key, e.value.arg, e.value.time, rt); - } - }) + for (def e = nextEvent(loadEvents()); e && e.event.time <= getTime(); e = nextEvent(loadEvents())) { + def f = namedEvents[e.event.func]; + removeEvent(e.name); + if (f) { + f(e.name, e.event.arg, e.event.time, rt); + } + } }; def sessionAborted = null; def gagText = { t, p -> |