Software / code / prosody
Diff
util/timer.lua @ 8685:2548111e71d6
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
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 23 Mar 2018 21:18:15 +0100 |
| parent | 8555:4f0f5b49bb03 |
| child | 8762:2f8523bf7ff2 |
line wrap: on
line diff
--- a/util/timer.lua Fri Mar 23 20:57:34 2018 +0100 +++ b/util/timer.lua Fri Mar 23 21:18:15 2018 +0100 @@ -10,6 +10,7 @@ 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 @@ 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; };