util/timer.lua
changeset 6933 58e260832334
parent 6839 9f45f0fe5aef
child 6934 5c2c8aeb4690
--- 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;