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 ipairs = ipairs;
21 local function _add_task(delay, func)
22 local current_time = get_time();
23 delay = delay + current_time;
24 if delay >= current_time then
25 t_insert(new_data, {delay, func});
31 ns_addtimer(function()
32 local current_time = get_time();
33 for _, d in ipairs(new_data) do
38 local t, func = data[i][1], data[i][2];
39 if t <= current_time then
42 if type(r) == "number" then _add_task(r, func); end