diff options
Diffstat (limited to 'util/async.lua')
-rw-r--r-- | util/async.lua | 8 |
1 files changed, 8 insertions, 0 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; }; |