For the latest stable version, please use Emilua API 0.10! |
mutex
local mutex = require('mutex')
local function ping_sender()
sleep(30)
scope(function()
scope_cleanup_push(function() ws_write_mtx:unlock() end)
ws_write_mtx:lock()
ws:ping()
end)
end
local function queue_consumer()
scope(function()
scope_cleanup_push(function() queue_mtx:unlock() end)
queue_mtx:lock()
while #queue == 0 do
queue_cond:wait(queue_mtx)
end
for _, e in ipairs(queue) do
consume_item(e)
end
queue = {}
end)
end
A mutex.