Comparison

util/async.lua @ 7361:3409773ca19a

Merge with Link Mauve
author Kim Alvefur <zash@zash.se>
date Sun, 17 Apr 2016 22:28:48 +0200
parent 7359:a5a080c12c96
child 7436:649b89b2c840
comparison
equal deleted inserted replaced
7360:7a37fade5380 7361:3409773ca19a
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;