aboutsummaryrefslogtreecommitdiffstats
path: root/util/async.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-07-08 00:37:01 +0200
committerKim Alvefur <zash@zash.se>2018-07-08 00:37:01 +0200
commit9c48fc472619e4a08278eb544f61ae7e62310e4b (patch)
tree2f67f67938b9ebd8a82242cedf6879f5cf149804 /util/async.lua
parentb58c44e43aab9f7f6c2793fc71bb2177e9e90084 (diff)
downloadprosody-9c48fc472619e4a08278eb544f61ae7e62310e4b.tar.gz
prosody-9c48fc472619e4a08278eb544f61ae7e62310e4b.zip
util.{async,timer}: Move sleep() to reduce dependencies of util.timer
Diffstat (limited to 'util/async.lua')
-rw-r--r--util/async.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/util/async.lua b/util/async.lua
index 4d9f159f..d1d78fa5 100644
--- a/util/async.lua
+++ b/util/async.lua
@@ -1,5 +1,6 @@
local logger = require "util.logger";
local log = logger.init("util.async");
+local timer = require "util.timer";
local new_id = require "util.id".short;
local function checkthread()
@@ -245,9 +246,16 @@ local function ready()
return pcall(checkthread);
end
+local function sleep(s)
+ local wait, done = waiter();
+ timer.add_task(s, done);
+ wait();
+end
+
return {
ready = ready;
waiter = waiter;
guarder = guarder;
runner = runner;
+ sleep = sleep;
};