From 40beef755f0c47691b5cd5a79e76fdd361320aa8 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 21 Nov 2021 16:37:08 +0100 Subject: Sleep for unused tick time & optional realtime - Optional luasocket dependency for realtime measurements (instead of CPU time) - lua_async.run() will wait for the time to be ready --- init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 07bea3e..368ffa9 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,13 @@ lua_async = {} +if rawget(_G, "require") then + lua_async.socket = require("socket") +end + +function lua_async.clock() + return lua_async.socket and lua_async.socket.gettime() or os.clock() +end + function lua_async.step(dtime) -- timers phase lua_async.timeouts.step(dtime) -- cgit v1.2.3