mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02:00
Implement minetest.ipc_poll()
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user