net.server_epoll: Make API-compatible with util.timer

This commit is contained in:
Kim Alvefur 2020-06-29 16:42:16 +02:00
parent 99b26ab45c
commit 927ef9f2f2

View file

@ -99,9 +99,9 @@ local function reschedule(t, time)
end end
-- Add relative timer -- Add relative timer
local function addtimer(timeout, f) local function addtimer(timeout, f, param)
local time = monotonic() + timeout; local time = monotonic() + timeout;
local timer = { time, f, close = closetimer, reschedule = reschedule, id = nil }; local timer = { time, f, param, close = closetimer, reschedule = reschedule, id = nil };
timer.id = timers:insert(timer, time); timer.id = timers:insert(timer, time);
return timer; return timer;
end end
@ -121,7 +121,7 @@ local function runtimers(next_delay, min_wait)
end end
local _, timer = timers:pop(); local _, timer = timers:pop();
local ok, ret = pcall(timer[2], now); local ok, ret = pcall(timer[2], now, timer, timer[3]);
if ok and type(ret) == "number" then if ok and type(ret) == "number" then
local next_time = elapsed+ret; local next_time = elapsed+ret;
timer[1] = next_time; timer[1] = next_time;