diff options
author | Kim Alvefur <zash@zash.se> | 2022-02-22 14:17:10 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-02-22 14:17:10 +0100 |
commit | ac06985604e2def6e1414113fd3266243b944303 (patch) | |
tree | cd0475228a34e4b81635f9486b70cce3fe709f7a /util | |
parent | 1d20ec63e66f04d0da8470d2f06c98be25960de7 (diff) | |
download | prosody-ac06985604e2def6e1414113fd3266243b944303.tar.gz prosody-ac06985604e2def6e1414113fd3266243b944303.zip |
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.
Diffstat (limited to 'util')
-rw-r--r-- | util/async.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/util/async.lua b/util/async.lua index ece589cb..2830238f 100644 --- a/util/async.lua +++ b/util/async.lua @@ -73,7 +73,7 @@ local function runner_continue(thread) 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 @@ local function waiter(num) 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; |