Software /
code /
prosody
Changeset
8995:2e6f7ab97794
util.{async,timer}: Move sleep() to reduce dependencies of util.timer
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 08 Jul 2018 00:37:01 +0200 |
parents | 8994:f17e768c1a99 |
children | 8996:2df7dc99566a |
files | util/async.lua util/timer.lua |
diffstat | 2 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/util/async.lua Sat Jul 07 21:55:18 2018 +0200 +++ b/util/async.lua Sun Jul 08 00:37:01 2018 +0200 @@ -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 @@ 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; };
--- a/util/timer.lua Sat Jul 07 21:55:18 2018 +0200 +++ b/util/timer.lua Sun Jul 08 00:37:01 2018 +0200 @@ -10,7 +10,6 @@ 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 @@ 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; };