projects
/
prosody.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util.async: waiter: Remove restriction about wait() being called before done()
[prosody.git]
/
util
/
async.lua
diff --git
a/util/async.lua
b/util/async.lua
index afbaba5c62df52e434b40040118db5fe4de1af63..c81f8639b490b30905af66ac3428e70fe6eedbe0 100644
(file)
--- a/
util/async.lua
+++ b/
util/async.lua
@@
-28,14
+28,15
@@
local function waiter(num)
error("Not running in an async context, see http://prosody.im/doc/developers/async");
end
num = num or 1;
error("Not running in an async context, see http://prosody.im/doc/developers/async");
end
num = num or 1;
+ local waiting;
return function ()
return function ()
+ if num == 0 then return; end -- already done
+ waiting = true;
coroutine.yield("wait");
end, function ()
num = num - 1;
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
end
end;
end