Software /
code /
prosody
Changeset
8651:1b7c5933b215
util.async: Add sleep() method
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 22 Mar 2018 13:02:00 +0000 |
parents | 8650:2f133b6e8740 |
children | 8652:03bb534593cb |
files | util/async.lua |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util/async.lua Thu Mar 22 11:56:03 2018 +0000 +++ b/util/async.lua Thu Mar 22 13:02:00 2018 +0000 @@ -1,5 +1,6 @@ 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(); @@ -233,10 +234,17 @@ end end +local function sleep(s) + local wait, done = waiter(); + timer.add_task(s, done); + wait(); +end + return { once = once; ready = ready; waiter = waiter; guarder = guarder; - runner = runner + runner = runner; + sleep = sleep; };