mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
review
This commit is contained in:
parent
0dbc30a88c
commit
5b6f9be18c
2 changed files with 5 additions and 4 deletions
|
@ -209,14 +209,14 @@ end
|
||||||
unittests.register("test_async_vector", test_vector_preserve, {async=true})
|
unittests.register("test_async_vector", test_vector_preserve, {async=true})
|
||||||
|
|
||||||
local function test_async_job_replacement(cb)
|
local function test_async_job_replacement(cb)
|
||||||
|
core.ipc_set("unittests:end_blocking", nil)
|
||||||
local capacity = core.get_async_threading_capacity()
|
local capacity = core.get_async_threading_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)
|
end, function() end)
|
||||||
end
|
end
|
||||||
local job = core.handle_async(function(x)
|
local job = core.handle_async(function()
|
||||||
return x
|
|
||||||
end, function()
|
end, function()
|
||||||
return cb("Canceled async job run")
|
return cb("Canceled async job run")
|
||||||
end)
|
end)
|
||||||
|
@ -229,7 +229,6 @@ 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
|
||||||
|
|
|
@ -11,7 +11,9 @@ static std::string get_serialized_function(lua_State *L, int index)
|
||||||
call_string_dump(L, index);
|
call_string_dump(L, index);
|
||||||
size_t func_length;
|
size_t func_length;
|
||||||
const char *serialized_func_raw = lua_tolstring(L, -1, &func_length);
|
const char *serialized_func_raw = lua_tolstring(L, -1, &func_length);
|
||||||
return std::string(serialized_func_raw, func_length);
|
std::string serialized_func(serialized_func_raw, func_length);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
return serialized_func;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do_async_callback(func, params, mod_origin)
|
// do_async_callback(func, params, mod_origin)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue