From 2fa049d2e15dba4aedba3e7009af45668c617823 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 23 Mar 2018 21:18:15 +0100 Subject: 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 --- util/timer.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util/timer.lua') 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; }; -- cgit v1.2.3