Diff

util/timer.lua @ 4413:ffa4bed1b716

util.timer: Variable name change (func -> callback)
author Matthew Wild <mwild1@gmail.com>
date Thu, 03 Nov 2011 12:47:52 +0000
parent 4385:c94167139f27
child 4751:0c7ae4bfc835
line wrap: on
line diff
--- a/util/timer.lua	Thu Nov 03 12:41:21 2011 +0000
+++ b/util/timer.lua	Thu Nov 03 12:47:52 2011 +0000
@@ -26,15 +26,15 @@
 
 local _add_task;
 if not event then
-	function _add_task(delay, func)
+	function _add_task(delay, callback)
 		local current_time = get_time();
 		delay = delay + current_time;
 		if delay >= current_time then
-			t_insert(new_data, {delay, func});
+			t_insert(new_data, {delay, callback});
 		else
-			local r = func();
+			local r = callback();
 			if r and type(r) == "number" then
-				return _add_task(r, func);
+				return _add_task(r, callback);
 			end
 		end
 	end
@@ -50,12 +50,12 @@
 		
 		local next_time = math_huge;
 		for i, d in pairs(data) do
-			local t, func = d[1], d[2];
+			local t, callback = d[1], d[2];
 			if t <= current_time then
 				data[i] = nil;
-				local r = func(current_time);
+				local r = callback(current_time);
 				if type(r) == "number" then
-					_add_task(r, func);
+					_add_task(r, callback);
 					next_time = math_min(next_time, r);
 				end
 			else
@@ -66,10 +66,10 @@
 	end);
 else
 	local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1;
-	function _add_task(delay, func)
+	function _add_task(delay, callback)
 		local event_handle;
 		event_handle = event_base:addevent(nil, 0, function ()
-			local ret = func();
+			local ret = callback();
 			if ret then
 				return 0, ret;
 			elseif event_handle then