Software /
code /
prosody
Diff
util/async.lua @ 10411:db2a06b9ff98
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 16 Nov 2019 16:52:31 +0100 |
parent | 10291:7b48b620164c |
child | 10928:79faf5b98395 |
line wrap: on
line diff
--- a/util/async.lua Sat Nov 16 16:45:33 2019 +0100 +++ b/util/async.lua Sat Nov 16 16:52:31 2019 +0100 @@ -246,9 +246,25 @@ return pcall(checkthread); end +local function wait(promise) + local async_wait, async_done = waiter(); + local ret, err = nil, nil; + promise:next( + function (r) ret = r; end, + function (e) err = e; end) + :finally(async_done); + async_wait(); + if ret then + return ret; + else + return nil, err; + end +end + return { ready = ready; waiter = waiter; guarder = guarder; runner = runner; + wait = wait; };