mirror of
https://github.com/kikito/cron.lua.git
synced 2024-12-19 18:34:20 +00:00
Rollback loop change (references #2)
Tests didn't pass. Further examination revealed that, even if the Lua standard seems to allow for eliminating table keys while parsing it in a loop, in reality those values remained in the table.
This commit is contained in:
parent
2a1ad28c94
commit
6e72b85232
6
cron.lua
6
cron.lua
@ -79,8 +79,12 @@ end
|
|||||||
function cron.update(dt)
|
function cron.update(dt)
|
||||||
assert(type(dt) == "number" and dt >= 0, "dt must be a non-negative number")
|
assert(type(dt) == "number" and dt >= 0, "dt must be a non-negative number")
|
||||||
|
|
||||||
|
local expired = {}
|
||||||
for id, entry in pairs(entries) do
|
for id, entry in pairs(entries) do
|
||||||
if entry:update(dt) then entry[id] = nil end
|
if entry:update(dt) then expired[id] = true end
|
||||||
|
end
|
||||||
|
for id,_ in pairs(expired) do
|
||||||
|
entries[id] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user