1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-12-20 00:35:47 +01:00

[Profnsched] lost jobs correction

Modified to replace # when we ant to count items in an array.
Code currently not cleaned after correction.
This commit is contained in:
Coethium
2016-10-29 16:25:57 +02:00
parent 7ddebddee2
commit 8a78752659
3 changed files with 55 additions and 26 deletions

View File

@@ -3,15 +3,23 @@ dofile(minetest.get_modpath("profnsched").."/queue.lua")
local jobs = {}
local scheduler = scheduler
function getnjobs()
return #jobs
end
-- For minetest.after replacement
local function check_expired_jobs()
local time = core.get_us_time()
local tjobs = {}
for i,job in pairs(jobs) do
if time >= job.expire then
scheduler.add(1, job)
jobs[i] = nil
--jobs[i] = nil
else
tjobs[#tjobs+1] = job
end
end
jobs = tjobs
scheduler.asap(4, check_expired_jobs)
end
scheduler.asap(4, check_expired_jobs)