equal
deleted
inserted
replaced
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 http://prosody.im/doc/developers/async"); |
29 end |
29 end |
30 num = num or 1; |
30 num = num or 1; |
|
31 local waiting; |
31 return function () |
32 return function () |
|
33 if num == 0 then return; end -- already done |
|
34 waiting = true; |
32 coroutine.yield("wait"); |
35 coroutine.yield("wait"); |
33 end, function () |
36 end, function () |
34 num = num - 1; |
37 num = num - 1; |
35 if num == 0 then |
38 if num == 0 and waiting then |
36 if not runner_continue(thread) then |
39 runner_continue(thread); |
37 error("done() called without wait()!"); |
|
38 end |
|
39 end |
40 end |
40 end; |
41 end; |
41 end |
42 end |
42 |
43 |
43 local runner_mt = {}; |
44 local runner_mt = {}; |