Software /
code /
prosody
Changeset
5792:aac4c6147647
util.async: waiter: Remove restriction about wait() being called before done()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 12 Aug 2013 12:08:51 +0100 |
parents | 5791:2c98061b6b1e |
children | 5793:e8c79796ead9 |
files | util/async.lua |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/util/async.lua Mon Aug 12 11:50:27 2013 +0100 +++ b/util/async.lua Mon Aug 12 12:08:51 2013 +0100 @@ -28,14 +28,15 @@ error("Not running in an async context, see http://prosody.im/doc/developers/async"); end num = num or 1; + local waiting; return function () + if num == 0 then return; end -- already done + waiting = true; coroutine.yield("wait"); end, function () num = num - 1; - if num == 0 then - if not runner_continue(thread) then - error("done() called without wait()!"); - end + if num == 0 and waiting then + runner_continue(thread); end end; end