diff options
author | Andrey Sobolev <haiodo@users.noreply.github.com> | 2017-03-01 15:43:24 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-01 09:43:24 +0100 |
commit | 78de355ec60322ca33c26641d967bcf67571b5d9 (patch) | |
tree | 88a31d4742f6b21c8291834e2ec8c344b5b6d4ec | |
parent | b47df72e77c127673ec603471a4b52ac31ef88b0 (diff) | |
download | Nim-78de355ec60322ca33c26641d967bcf67571b5d9.tar.gz |
Fix async timers execution. (#5448)
-rw-r--r-- | lib/pure/asyncdispatch.nim | 6 | ||||
-rw-r--r-- | lib/upcoming/asyncdispatch.nim | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index 7fa686f00..1696c4ed9 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -167,8 +167,12 @@ type callbacks: Deque[proc ()] proc processTimers(p: PDispatcherBase) {.inline.} = - while p.timers.len > 0 and epochTime() >= p.timers[0].finishAt: + #Process just part if timers at a step + var count = p.timers.len + let t = epochTime() + while count > 0 and t >= p.timers[0].finishAt: p.timers.pop().fut.complete() + dec count proc processPendingCallbacks(p: PDispatcherBase) = while p.callbacks.len > 0: diff --git a/lib/upcoming/asyncdispatch.nim b/lib/upcoming/asyncdispatch.nim index 1787f062f..feee87bae 100644 --- a/lib/upcoming/asyncdispatch.nim +++ b/lib/upcoming/asyncdispatch.nim @@ -138,8 +138,12 @@ type callbacks: Deque[proc ()] proc processTimers(p: PDispatcherBase) {.inline.} = - while p.timers.len > 0 and epochTime() >= p.timers[0].finishAt: + #Process just part if timers at a step + var count = p.timers.len + let t = epochTime() + while count > 0 and t >= p.timers[0].finishAt: p.timers.pop().fut.complete() + dec count proc processPendingCallbacks(p: PDispatcherBase) = while p.callbacks.len > 0: |