aboutsummaryrefslogtreecommitdiffstats
path: root/util/timer.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-03-23 21:18:15 +0100
committerKim Alvefur <zash@zash.se>2018-03-23 21:18:15 +0100
commit4872683a4207ad04e2adc611687dea3c7f729dc6 (patch)
tree44ff62ca6b47b65e3399564c5c4f4fe5cecfe5ea /util/timer.lua
parentfdcc458ff81cf531cb3ed593b7027651609b4a3b (diff)
downloadprosody-4872683a4207ad04e2adc611687dea3c7f729dc6.tar.gz
prosody-4872683a4207ad04e2adc611687dea3c7f729dc6.zip
util.timer: Move sleep() here from util.async
This is to solve a indirect dependency issue where net.server was initialized before the config was read
Diffstat (limited to 'util/timer.lua')
-rw-r--r--util/timer.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/util/timer.lua b/util/timer.lua
index ff834068..70678ab2 100644
--- a/util/timer.lua
+++ b/util/timer.lua
@@ -10,6 +10,7 @@ local indexedbheap = require "util.indexedbheap";
local log = require "util.logger".init("timer");
local server = require "net.server";
local get_time = require "util.time".now
+local async = require "util.async";
local type = type;
local debug_traceback = debug.traceback;
local tostring = tostring;
@@ -102,9 +103,16 @@ local function reschedule(id, delay)
return id;
end
+local function sleep(s)
+ local wait, done = async.waiter();
+ add_task(s, done);
+ wait();
+end
+
return {
add_task = add_task;
stop = stop;
reschedule = reschedule;
+ sleep = sleep;
};