aboutsummaryrefslogtreecommitdiffstats
path: root/util
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
commit701f263ee70bf1da7c26166b07e2d26889cd2bf8 (patch)
tree2f67f67938b9ebd8a82242cedf6879f5cf149804 /util
parent32e7b31ec7d96b76d411827f1ff0f4ed6336eb10 (diff)
downloadprosody-701f263ee70bf1da7c26166b07e2d26889cd2bf8.tar.gz
prosody-701f263ee70bf1da7c26166b07e2d26889cd2bf8.zip
util.{async,timer}: Move sleep() to reduce dependencies of util.timer
Diffstat (limited to 'util')
-rw-r--r--util/async.lua8
-rw-r--r--util/timer.lua8
2 files changed, 8 insertions, 8 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;
};
diff --git a/util/timer.lua b/util/timer.lua
index 424d44fa..22f547df 100644
--- a/util/timer.lua
+++ b/util/timer.lua
@@ -10,7 +10,6 @@ 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;
@@ -104,16 +103,9 @@ 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;
};