]> git.lizzy.rs Git - lua_async.git/blob - init.lua
Merge branch 'master' of https://github.com/EliasFleckenstein03/lua_async
[lua_async.git] / init.lua
1 lua_async = {
2         poll_functions = {},
3 }
4
5 function lua_async.clock()
6         return lua_async.socket and lua_async.socket.gettime() or os.clock()
7 end
8
9 function lua_async.step(dtime)
10         -- timers phase
11         lua_async.timeouts.step(dtime)
12         lua_async.intervals.step(dtime)
13
14         -- pending callbacks phase is obsolete
15
16         -- idle & prepare phase are obsolete
17
18         -- poll phase
19         for func in pairs(lua_async.poll_functions) do
20                 func()
21         end
22
23         -- check phase
24         lua_async.immediates.step(dtime)
25
26         -- close phase is obsolete
27 end
28
29 return function(path, no_socket)
30         if not no_socket then
31                 lua_async.socket = require("socket")
32         end
33
34         for _, f in ipairs {
35                 "timeouts",
36                 "intervals",
37                 "immediates",
38                 "promises",
39                 "async_await",
40                 "util",
41                 "limiting",
42                 "events",
43         } do
44                 dofile(path .. "/" .. f .. ".lua")
45         end
46 end