1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

review async unblocking

This commit is contained in:
y5nw 2024-11-28 12:51:01 +01:00
parent 923f2f1979
commit 0dbc30a88c

View file

@ -210,16 +210,10 @@ unittests.register("test_async_vector", test_vector_preserve, {async=true})
local function test_async_job_replacement(cb) local function test_async_job_replacement(cb)
local capacity = core.get_async_threading_capacity() local capacity = core.get_async_threading_capacity()
local running = capacity
for _ = 1, capacity do for _ = 1, capacity do
core.handle_async(function() core.handle_async(function()
core.ipc_poll("unittests:end_blocking", 1000) core.ipc_poll("unittests:end_blocking", 1000)
end, function() end, function() end)
running = running - 1
if running <= 0 then
core.ipc_set("unittests:end_blocking", nil)
end
end)
end end
local job = core.handle_async(function(x) local job = core.handle_async(function(x)
return x return x
@ -235,6 +229,7 @@ local function test_async_job_replacement(cb)
job = core.handle_async(function(x) job = core.handle_async(function(x)
return x return x
end, function(ret) end, function(ret)
core.ipc_set("unittests:end_blocking", nil)
if job:cancel() then if job:cancel() then
return cb("AsyncJob:cancel canceled a completed job") return cb("AsyncJob:cancel canceled a completed job")
end end