Mercurial > prosody-hg
comparison util/async.lua @ 8237:f81cd9aaf994
util.async: Fix documentation URL
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Fri, 15 Sep 2017 17:17:07 -0400 |
| parents | f928695a2af1 |
| children | f652e1ea2f69 |
comparison
equal
deleted
inserted
replaced
| 8236:4878e4159e12 | 8237:f81cd9aaf994 |
|---|---|
| 25 end | 25 end |
| 26 | 26 |
| 27 local function waiter(num) | 27 local function waiter(num) |
| 28 local thread = coroutine.running(); | 28 local thread = coroutine.running(); |
| 29 if not thread then | 29 if not thread then |
| 30 error("Not running in an async context, see https://prosody.im/doc/developers/async"); | 30 error("Not running in an async context, see https://prosody.im/doc/developers/util/async"); |
| 31 end | 31 end |
| 32 num = num or 1; | 32 num = num or 1; |
| 33 local waiting; | 33 local waiting; |
| 34 return function () | 34 return function () |
| 35 if num == 0 then return; end -- already done | 35 if num == 0 then return; end -- already done |
| 48 local function guarder() | 48 local function guarder() |
| 49 local guards = {}; | 49 local guards = {}; |
| 50 return function (id, func) | 50 return function (id, func) |
| 51 local thread = coroutine.running(); | 51 local thread = coroutine.running(); |
| 52 if not thread then | 52 if not thread then |
| 53 error("Not running in an async context, see https://prosody.im/doc/developers/async"); | 53 error("Not running in an async context, see https://prosody.im/doc/developers/util/async"); |
| 54 end | 54 end |
| 55 local guard = guards[id]; | 55 local guard = guards[id]; |
| 56 if not guard then | 56 if not guard then |
| 57 guard = {}; | 57 guard = {}; |
| 58 guards[id] = guard; | 58 guards[id] = guard; |
