local tostring = tostring;
local xpcall = xpcall;
-module "timer"
+local _ENV = nil;
local _add_task = server.add_task;
---add_task = _add_task;
local h = indexedbheap.create();
local params = {};
return peek - now;
end
end
-function add_task(delay, callback, param)
+local function add_task(delay, callback, param)
local current_time = get_time();
local event_time = current_time + delay;
end
return id;
end
-function stop(id)
+local function stop(id)
params[id] = nil;
return h:remove(id);
end
-function reschedule(id, delay)
+local function reschedule(id, delay)
local current_time = get_time();
local event_time = current_time + delay;
h:reprioritize(id, delay);
return id;
end
-return _M;
+return {
+ add_task = add_task;
+ stop = stop;
+ reschedule = reschedule;
+};
+