summaryrefslogtreecommitdiff
path: root/xmake/core/base/timer.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2019-12-16 22:35:22 +0800
committerruki <[email protected]>2019-12-16 09:32:12 +0800
commit61d1ac3a859d4b81858483c6496c4d2125150b1c (patch)
tree8c1cb4f8869c9e78c4c0f84c03e7eb851d3a7e21 /xmake/core/base/timer.lua
parent4ed6741dd366d1e48d30356657bc77d40e0ac2ca (diff)
improve timer
Diffstat (limited to 'xmake/core/base/timer.lua')
-rw-r--r--xmake/core/base/timer.lua7
1 files changed, 3 insertions, 4 deletions
diff --git a/xmake/core/base/timer.lua b/xmake/core/base/timer.lua
index d2120b466..c04b166b0 100644
--- a/xmake/core/base/timer.lua
+++ b/xmake/core/base/timer.lua
@@ -77,12 +77,11 @@ function timer:next()
local triggered = false
local task = tasks:peek()
if task then
- -- timeout?
- local now = os.mclock()
- if task.when <= now then
+ -- timeout or canceled?
+ if task.cancel or task.when <= os.mclock() then
tasks:pop()
if task.continuous and not task.cancel then
- task.when = now + task.period
+ task.when = os.mclock() + task.period
tasks:push(task)
end
-- run timer task