Software /
code /
prosody
Changeset
12310:91af1697ddd8
util.async: Optionally allow too many 'done' callbacks
Sometimes, like in mod_c2s and mod_s2s during shutdown, all you want is
to wait for the first done() and not complicate things.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 22 Feb 2022 14:17:10 +0100 |
parents | 12309:926a6c5d13e7 |
children | 12311:bc30e1b9ad89 |
files | util/async.lua |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/util/async.lua Tue Feb 22 12:35:31 2022 +0100 +++ b/util/async.lua Tue Feb 22 14:17:10 2022 +0100 @@ -73,7 +73,7 @@ return true; end -local function waiter(num) +local function waiter(num, allow_many) local thread = checkthread(); num = num or 1; local waiting; @@ -85,7 +85,7 @@ num = num - 1; if num == 0 and waiting then runner_continue(thread); - elseif num < 0 then + elseif not allow_many and num < 0 then error("done() called too many times"); end end;