Comparison

util/timer.lua @ 5880:11f14d44438e

util.timer: Import all require upvalues.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 30 Oct 2013 17:58:17 -0400
parent 5879:95f1d5421fbc
child 5898:bf9aba718c01
comparison
equal deleted inserted replaced
5879:95f1d5421fbc 5880:11f14d44438e
13 local math_huge = math.huge 13 local math_huge = math.huge
14 local get_time = require "socket".gettime; 14 local get_time = require "socket".gettime;
15 local t_insert = table.insert; 15 local t_insert = table.insert;
16 local pairs = pairs; 16 local pairs = pairs;
17 local type = type; 17 local type = type;
18 local debug_traceback = debug.traceback;
19 local tostring = tostring;
20 local xpcall = xpcall;
18 21
19 local data = {}; 22 local data = {};
20 local new_data = {}; 23 local new_data = {};
21 24
22 module "timer" 25 module "timer"
85 local h = indexedbheap.create(); 88 local h = indexedbheap.create();
86 local params = {}; 89 local params = {};
87 local next_time = nil; 90 local next_time = nil;
88 local _id, _callback, _now, _param; 91 local _id, _callback, _now, _param;
89 local function _call() return _callback(_now, _id, _param); end 92 local function _call() return _callback(_now, _id, _param); end
90 local function _traceback_handler(err) log("error", "Traceback[timer]: %s", traceback(tostring(err), 2)); end 93 local function _traceback_handler(err) log("error", "Traceback[timer]: %s", debug_traceback(tostring(err), 2)); end
91 local function _on_timer(now) 94 local function _on_timer(now)
92 local peek; 95 local peek;
93 while true do 96 while true do
94 peek = h:peek(); 97 peek = h:peek();
95 if peek == nil or peek > now then break; end 98 if peek == nil or peek > now then break; end