aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-11-21 18:11:40 +0000
committerMatthew Wild <mwild1@gmail.com>2023-11-21 18:11:40 +0000
commitab26786924b3b5871cba11f5f2fe265a95480881 (patch)
tree68c9dadf212c95732a342f7f7371a39297ac20e6
parentc8e2129a82d666571b48232f39bfae30a0470db2 (diff)
downloadprosody-ab26786924b3b5871cba11f5f2fe265a95480881.tar.gz
prosody-ab26786924b3b5871cba11f5f2fe265a95480881.zip
util.async: Export a table of currently-waiting runners
This can be used for debugging and introspection.
-rw-r--r--util/async.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/async.lua b/util/async.lua
index e35aff26..ff88ad17 100644
--- a/util/async.lua
+++ b/util/async.lua
@@ -2,6 +2,7 @@ local logger = require "prosody.util.logger";
local log = logger.init("util.async");
local new_id = require "prosody.util.id".short;
local xpcall = require "prosody.util.xpcall".xpcall;
+local time_now = require "prosody.util.time".now;
local function checkthread()
local thread, main = coroutine.running();
@@ -138,6 +139,8 @@ end
local runner_mt = {};
runner_mt.__index = runner_mt;
+local waiting_runners = {};
+
local function runner_create_thread(func, self)
local thread = coroutine.create(function (self) -- luacheck: ignore 432/self
while true do
@@ -234,6 +237,7 @@ function runner_mt:run(input)
if n > 0 then
return self:run();
end
+ waiting_runners[self] = state == "waiting" and time_now() or nil;
return true, state, n;
end
@@ -293,4 +297,5 @@ return {
set_nexttick = function(new_next_tick) next_tick = new_next_tick; end;
set_schedule_function = function (new_schedule_function) schedule_task = new_schedule_function; end;
+ waiting_runners = waiting_runners;
};