aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-11-21 16:50:09 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-11-21 16:50:09 +0100
commitd53a22a712fd272cac72353fceae366aa1792c5f (patch)
tree87d551b77ebe58797eee031ef6fbc7fcf9b9dd96
parent40beef755f0c47691b5cd5a79e76fdd361320aa8 (diff)
downloadlua_async-d53a22a712fd272cac72353fceae366aa1792c5f.tar.xz
Subtract dtime from sleep time
-rw-r--r--util.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/util.lua b/util.lua
index dbef0b5..3af0ffd 100644
--- a/util.lua
+++ b/util.lua
@@ -39,11 +39,11 @@ function lua_async.run()
local next = math.huge
- for _, timeout in pairs(lua_async.timeouts.pool)
+ for _, timeout in pairs(lua_async.timeouts.pool) do
next = math.min(next, timeout.time_left)
end
- for _, interval in pairs(lua_async.intervals.pool)
+ for _, interval in pairs(lua_async.intervals.pool) do
next = math.min(next, interval.time_left)
end
@@ -51,6 +51,8 @@ function lua_async.run()
return
end
- lua_async.socket.sleep(next)
+ if next > dtime then
+ lua_async.socket.sleep(next - dtime)
+ end
end
end