diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/async.lua | 8 | ||||
-rw-r--r-- | util/timer.lua | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/util/async.lua b/util/async.lua index 8b92c878..012cfd87 100644 --- a/util/async.lua +++ b/util/async.lua @@ -1,6 +1,5 @@ local log = require "util.logger".init("util.async"); local new_id = require "util.id".short; -local timer = require "util.timer"; local function checkthread() local thread, main = coroutine.running(); @@ -226,16 +225,9 @@ 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 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; }; |