Software /
code /
prosody
Comparison
util/async.lua @ 8611:937de0c39279
util.async: Add comment
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 16 Mar 2018 22:31:12 +0000 |
parent | 8610:b03c7884fade |
child | 8613:dbb4788db8e3 |
comparison
equal
deleted
inserted
replaced
8610:b03c7884fade | 8611:937de0c39279 |
---|---|
19 if not ok then | 19 if not ok then |
20 local err = state; | 20 local err = state; |
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 -- Find the 'level' of the top-most function (0 == current level, 1 == caller, ...) | |
24 while debug.getinfo(thread, level, "") do level = level + 1; end | 25 while debug.getinfo(thread, level, "") do level = level + 1; end |
25 ok, runner = debug.getlocal(thread, level-1, 1); | 26 ok, runner = debug.getlocal(thread, level-1, 1); |
26 assert(ok == "self", "unexpected async state: variable mismatch"); | 27 assert(ok == "self", "unexpected async state: variable mismatch"); |
27 assert(runner.thread == thread, "unexpected async state: thread mismatch"); | 28 assert(runner.thread == thread, "unexpected async state: thread mismatch"); |
28 local error_handler = runner.watchers.error; | 29 local error_handler = runner.watchers.error; |