]> git.lizzy.rs Git - lua_async.git/commitdiff
Subtract dtime from sleep time
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 21 Nov 2021 15:50:09 +0000 (16:50 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 21 Nov 2021 15:50:09 +0000 (16:50 +0100)
util.lua

index dbef0b5275c6bace9051442fb88cb067ad90c1f3..3af0ffdb69aeda81dee1e18bb18160f7e8ee11a1 100644 (file)
--- 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