diff options
author | Matthew Wild <mwild1@gmail.com> | 2023-11-21 18:13:42 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2023-11-21 18:13:42 +0000 |
commit | ac680a900ea17ac70ca2de94bc52f2c9cf5a2ace (patch) | |
tree | e0f460d644b6126aa683b40429ca9eb0b1a6a5df /util | |
parent | 9e43a7742ab4f6e44c76158284f95f8b3ce520c4 (diff) | |
download | prosody-ac680a900ea17ac70ca2de94bc52f2c9cf5a2ace.tar.gz prosody-ac680a900ea17ac70ca2de94bc52f2c9cf5a2ace.zip |
util.async: Record current work item in the runner object
Mostly expected to be useful for debugging purposes.
Diffstat (limited to 'util')
-rw-r--r-- | util/async.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/async.lua b/util/async.lua index b225cc72..a510f80d 100644 --- a/util/async.lua +++ b/util/async.lua @@ -201,6 +201,7 @@ function runner_mt:run(input) for i = 1,n do local queued_input = q[i]; self:log("Resuming thread with new item [%s]", thread); + self.current_item = queued_input; local ok, new_state = coroutine.resume(thread, queued_input); if not ok then -- There was an error running the coroutine, save the error, mark runner as ready to begin again @@ -227,6 +228,10 @@ function runner_mt:run(input) end -- Runner processed all items it can, so save current runner state self.state = state; + if state == "ready" and self.current_item then + self.current_item = nil; + end + if err or state ~= self.notified_state then self:log("debug", "changed state from %s to %s [%s %s]", self.notified_state, err and ("error ("..state..")") or state, self.thread, self.thread and coroutine.status(self.thread)); if err then |