Software /
code /
prosody
Changeset
6930:58e260832334
util.timer: Keep count of how many timer instances are active
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 22 Nov 2015 17:18:29 +0100 |
parents | 6929:03bc9e197fcc |
children | 6931:5c2c8aeb4690 |
files | util/timer.lua |
diffstat | 1 files changed, 3 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/timer.lua Sun Nov 22 17:00:43 2015 +0100 +++ b/util/timer.lua Sun Nov 22 17:18:29 2015 +0100 @@ -19,6 +19,7 @@ local _add_task = server.add_task; +local _active_timers = 0; local h = indexedbheap.create(); local params = {}; local next_time = nil; @@ -46,6 +47,7 @@ if peek ~= nil then return peek - now; end + _active_timers = _active_timers - 1; end local function add_task(delay, callback, param) local current_time = get_time(); @@ -55,6 +57,7 @@ params[id] = param; if next_time == nil or event_time < next_time then next_time = event_time; + _active_timers = _active_timers + 1; _add_task(next_time - current_time, _on_timer); end return id;