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