equal
deleted
inserted
replaced
23 end |
23 end |
24 |
24 |
25 local function waiter(num) |
25 local function waiter(num) |
26 local thread = coroutine.running(); |
26 local thread = coroutine.running(); |
27 if not thread then |
27 if not thread then |
28 error("Not running in an async context, see http://prosody.im/doc/developers/async"); |
28 error("Not running in an async context, see https://prosody.im/doc/developers/async"); |
29 end |
29 end |
30 num = num or 1; |
30 num = num or 1; |
31 local waiting; |
31 local waiting; |
32 return function () |
32 return function () |
33 if num == 0 then return; end -- already done |
33 if num == 0 then return; end -- already done |
46 local function guarder() |
46 local function guarder() |
47 local guards = {}; |
47 local guards = {}; |
48 return function (id, func) |
48 return function (id, func) |
49 local thread = coroutine.running(); |
49 local thread = coroutine.running(); |
50 if not thread then |
50 if not thread then |
51 error("Not running in an async context, see http://prosody.im/doc/developers/async"); |
51 error("Not running in an async context, see https://prosody.im/doc/developers/async"); |
52 end |
52 end |
53 local guard = guards[id]; |
53 local guard = guards[id]; |
54 if not guard then |
54 if not guard then |
55 guard = {}; |
55 guard = {}; |
56 guards[id] = guard; |
56 guards[id] = guard; |