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

Implement minetest.ipc_poll()

This commit is contained in:
sfan5 2024-05-28 23:04:08 +02:00
parent 72801d0233
commit d2b4c27f21
5 changed files with 61 additions and 0 deletions

View file

@ -279,3 +279,18 @@ local function test_ipc_vector_preserve(cb)
assert(vector.check(v))
end
unittests.register("test_ipc_vector_preserve", test_ipc_vector_preserve)
local function test_ipc_poll(cb)
core.ipc_set("unittests:flag", nil)
assert(core.ipc_poll("unittests:flag", 1) == false)
-- Note that unlike the async result callback - which has to wait for the
-- next server step - the IPC is instant
local t0 = core.get_us_time()
core.handle_async(function()
core.ipc_set("unittests:flag", true)
end, function() end)
assert(core.ipc_poll("unittests:flag", 1000) == true, "Wait failed (or slow machine?)")
print("delta: " .. (core.get_us_time() - t0) .. "us")
end
unittests.register("test_ipc_poll", test_ipc_poll)