mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2025-01-04 07:37:31 +01:00
Fix crash when tasks are scheduled for the next timestep into priority 2 from inside a function dispatched from priority 2
This commit is contained in:
parent
528531e37b
commit
06b8fa561e
@ -132,6 +132,7 @@ local function globalstep(dtime)
|
|||||||
-- Run tasks that must be run this timestep (now-main)
|
-- Run tasks that must be run this timestep (now-main)
|
||||||
every_globalstep(dtime)
|
every_globalstep(dtime)
|
||||||
local next_main_task = run_queue[2]
|
local next_main_task = run_queue[2]
|
||||||
|
run_queue[2] = nil
|
||||||
while next_main_task do
|
while next_main_task do
|
||||||
local task = next_main_task
|
local task = next_main_task
|
||||||
next_main_task = task.next
|
next_main_task = task.next
|
||||||
@ -139,7 +140,6 @@ local function globalstep(dtime)
|
|||||||
task:func(dtime)
|
task:func(dtime)
|
||||||
free_task(task)
|
free_task(task)
|
||||||
end
|
end
|
||||||
run_queue[2] = nil
|
|
||||||
|
|
||||||
-- Launch asynchronous tasks that may be issued any time (background-async)
|
-- Launch asynchronous tasks that may be issued any time (background-async)
|
||||||
local next_background_async_task = run_queue[3]
|
local next_background_async_task = run_queue[3]
|
||||||
|
@ -190,5 +190,16 @@ describe('vl_scheduler',function()
|
|||||||
call_globalstep(0.05)
|
call_globalstep(0.05)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
it('can schedule new tasks recursively and they run on the next timestep',function()
|
||||||
|
local vl_scheduler = _G.vl_scheduler
|
||||||
|
vl_scheduler.after(0, 2, function() end)
|
||||||
|
vl_scheduler.after(0, 2, function()
|
||||||
|
vl_scheduler.after(0, 2, function() end)
|
||||||
|
vl_scheduler.after(0, 2, function() end)
|
||||||
|
end)
|
||||||
|
assert.no_error(function()
|
||||||
|
call_globalstep(0.05)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user