2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
10 local ns_addtimer = require "net.server".addtimer;
11 local get_time = os.time;
12 local t_insert = table.insert;
13 local t_remove = table.remove;
14 local ipairs, pairs = ipairs, pairs;
22 local function _add_task(delay, func)
23 local current_time = get_time();
24 delay = delay + current_time;
25 if delay >= current_time then
26 t_insert(new_data, {delay, func});
32 ns_addtimer(function()
33 local current_time = get_time();
35 for _, d in pairs(new_data) do
41 for i, d in pairs(data) do
42 local t, func = d[1], d[2];
43 if t <= current_time then
46 if type(r) == "number" then _add_task(r, func); end