aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-22 13:02:00 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-22 13:02:00 +0000
commitf90a032fb690903079e1dde5dc414c994fc6f2b2 (patch)
tree53be874f1e725fe9ed68f9cb5a57c9b58d17c94f
parentcdff82828c31d14b805213c68b8040ff2958d291 (diff)
downloadprosody-f90a032fb690903079e1dde5dc414c994fc6f2b2.tar.gz
prosody-f90a032fb690903079e1dde5dc414c994fc6f2b2.zip
util.async: Add sleep() method
-rw-r--r--util/async.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/util/async.lua b/util/async.lua
index 8e75a524..7a8bd686 100644
--- a/util/async.lua
+++ b/util/async.lua
@@ -1,5 +1,6 @@
local log = require "util.logger".init("util.async");
local new_id = require "util.id".short;
+local timer = require "util.timer";
local function checkthread()
local thread, main = coroutine.running();
@@ -233,10 +234,17 @@ do
end
end
+local function sleep(s)
+ local wait, done = waiter();
+ timer.add_task(s, done);
+ wait();
+end
+
return {
once = once;
ready = ready;
waiter = waiter;
guarder = guarder;
- runner = runner
+ runner = runner;
+ sleep = sleep;
};