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:
parent
72801d0233
commit
d2b4c27f21
5 changed files with 61 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue