]> git.lizzy.rs Git - lua_async.git/blobdiff - limiting.lua
Sleep for unused tick time & optional realtime
[lua_async.git] / limiting.lua
index d5df4486897bdc5a992257f89c1220ac08de048f..394006de1d37a273ab8ed5fb1275d65df31745a3 100644 (file)
@@ -13,7 +13,7 @@ function lua_async.set_limit(ms)
 
        lua_async.limiting.pool[co] = {
                limit = limit,
-               next_yield = os.clock() + limit,
+               next_yield = lua_async.clock() + limit,
        }
 end
 
@@ -26,9 +26,9 @@ function lua_async.check_limit()
        local co = assert(coroutine.running(), "check_limit called outside of an async function")
        local limit = lua_async.limiting.pool[co]
 
-       if limit and os.clock() >= limit.next_yield then
+       if limit and lua_async.clock() >= limit.next_yield then
                lua_async.yield()
-               limit.next_yield = os.clock() + limit.limit
+               limit.next_yield = lua_async.clock() + limit.limit
                return true
        end