]> git.lizzy.rs Git - lua_async.git/commitdiff
Merge branch 'master' of https://github.com/EliasFleckenstein03/lua_async master
authorElias Fleckenstein <eliasfleckenstein@web.de>
Tue, 14 Dec 2021 17:11:51 +0000 (18:11 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Tue, 14 Dec 2021 17:11:51 +0000 (18:11 +0100)
1  2 
init.lua

diff --combined init.lua
index 4de726a230ffbe85c359edfe17b8c64a8b048e99,b5cb92e17f932a15376d939aad213b2fa186574a..8449a0f1e2c6d962298f08031fd29da90d9edbb0
+++ b/init.lua
@@@ -1,11 -1,5 +1,7 @@@
 -lua_async = {}
 +lua_async = {
 +      poll_functions = {},
 +}
  
- 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
@@@ -15,14 -9,11 +11,14 @@@ function lua_async.step(dtime
        lua_async.timeouts.step(dtime)
        lua_async.intervals.step(dtime)
  
 -      -- pending callbacks phase is done by minetest
 +      -- pending callbacks phase is obsolete
  
        -- idle & prepare phase are obsolete
  
 -      -- poll phase is obsolete
 +      -- poll phase
 +      for func in pairs(lua_async.poll_functions) do
 +              func()
 +      end
  
        -- check phase
        lua_async.immediates.step(dtime)
        -- close phase is obsolete
  end
  
- return function(path)
+ return function(path, no_socket)
+       if not no_socket then
+               lua_async.socket = require("socket")
+       end
        for _, f in ipairs {
                "timeouts",
                "intervals",
@@@ -41,6 -36,6 +41,6 @@@
                "limiting",
                "events",
        } do
 -              dofile(path .. f .. ".lua")
 +              dofile(path .. "/" .. f .. ".lua")
        end
  end