Software /
code /
prosody
Comparison
util/async.lua @ 8683:867ac771fb6e
util.async: Remove async.once(), can now be replaced by runner():run(func)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 23 Mar 2018 14:22:01 +0000 |
parent | 8681:0c077800cd70 |
child | 8684:801f253ef52d |
comparison
equal
deleted
inserted
replaced
8682:151ecd18d624 | 8683:867ac771fb6e |
---|---|
224 | 224 |
225 local function ready() | 225 local function ready() |
226 return pcall(checkthread); | 226 return pcall(checkthread); |
227 end | 227 end |
228 | 228 |
229 local once; -- forward declaration | |
230 do | |
231 local once_watchers = { | |
232 error = function (_, err) | |
233 error(err); | |
234 end; | |
235 }; | |
236 local function once_runner(func) func(); end | |
237 function once(func) | |
238 local r = runner(once_runner, once_watchers); | |
239 return r:run(func); | |
240 end | |
241 end | |
242 | |
243 local function sleep(s) | 229 local function sleep(s) |
244 local wait, done = waiter(); | 230 local wait, done = waiter(); |
245 timer.add_task(s, done); | 231 timer.add_task(s, done); |
246 wait(); | 232 wait(); |
247 end | 233 end |