aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-22 07:46:23 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-22 07:46:23 +0000
commit430eef84208c1e4a0d07a2b32d76dccea731ca13 (patch)
tree849da7e4f75b2bc0551d160f470f1601192e2fe5 /util
parent8e469e0a76088d18886784fba9fc044c692987d4 (diff)
downloadprosody-430eef84208c1e4a0d07a2b32d76dccea731ca13.tar.gz
prosody-430eef84208c1e4a0d07a2b32d76dccea731ca13.zip
util.async: Add ready() to check whether running in async context
Diffstat (limited to 'util')
-rw-r--r--util/async.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/async.lua b/util/async.lua
index 374a3bdf..1930d1a9 100644
--- a/util/async.lua
+++ b/util/async.lua
@@ -215,4 +215,8 @@ function runner_mt:log(level, fmt, ...)
return log(level, "[runner %s] "..fmt, self.id, ...);
end
-return { waiter = waiter, guarder = guarder, runner = runner };
+local function ready()
+ return pcall(checkthread);
+end
+
+return { ready = ready, waiter = waiter, guarder = guarder, runner = runner };