# HG changeset patch # User Matthew Wild # Date 1700590422 0 # Node ID 17cb965e55b76d54b9835fbe497e4efbb044f45f # Parent 5206314d6c70c67dbadd948fc573f37e5e41ec9c util.async: Record current work item in the runner object Mostly expected to be useful for debugging purposes. diff -r 5206314d6c70 -r 17cb965e55b7 util/async.lua --- a/util/async.lua Tue Nov 21 18:12:49 2023 +0000 +++ b/util/async.lua Tue Nov 21 18:13:42 2023 +0000 @@ -201,6 +201,7 @@ 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 @@ 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