Mercurial > prosody-hg
comparison util/async.lua @ 8610:b03c7884fade
util.async: You can never have too many asserts!
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 16 Mar 2018 22:30:25 +0000 |
| parents | 9f6ab206d741 |
| children | 937de0c39279 |
comparison
equal
deleted
inserted
replaced
| 8609:9f6ab206d741 | 8610:b03c7884fade |
|---|---|
| 21 -- Running the coroutine failed, which means we have to find the runner manually, | 21 -- Running the coroutine failed, which means we have to find the runner manually, |
| 22 -- in order to inform the error handler | 22 -- in order to inform the error handler |
| 23 local level = 0; | 23 local level = 0; |
| 24 while debug.getinfo(thread, level, "") do level = level + 1; end | 24 while debug.getinfo(thread, level, "") do level = level + 1; end |
| 25 ok, runner = debug.getlocal(thread, level-1, 1); | 25 ok, runner = debug.getlocal(thread, level-1, 1); |
| 26 assert(ok == "self", "unexpected async state: variable mismatch"); | |
| 27 assert(runner.thread == thread, "unexpected async state: thread mismatch"); | |
| 26 local error_handler = runner.watchers.error; | 28 local error_handler = runner.watchers.error; |
| 27 if error_handler then error_handler(runner, debug.traceback(thread, err)); end | 29 if error_handler then error_handler(runner, debug.traceback(thread, err)); end |
| 28 local ready_handler = runner.watchers.ready; | 30 local ready_handler = runner.watchers.ready; |
| 29 runner.state, runner.thread = "ready", nil; | 31 runner.state, runner.thread = "ready", nil; |
| 30 if ready_handler then ready_handler(runner); end | 32 if ready_handler then ready_handler(runner); end |
