#283 common cleanup, added lockbox version to crash dump, changed crash handler to pcall requires for graphics/lockbox
This commit is contained in:
@@ -4,6 +4,14 @@
|
||||
|
||||
local mqueue = {}
|
||||
|
||||
---@class queue_item
|
||||
---@field qtype MQ_TYPE
|
||||
---@field message any
|
||||
|
||||
---@class queue_data
|
||||
---@field key any
|
||||
---@field val any
|
||||
|
||||
---@enum MQ_TYPE
|
||||
local TYPE = {
|
||||
COMMAND = 0,
|
||||
@@ -13,22 +21,14 @@ local TYPE = {
|
||||
|
||||
mqueue.TYPE = TYPE
|
||||
|
||||
local insert = table.insert
|
||||
local remove = table.remove
|
||||
|
||||
-- create a new message queue
|
||||
---@nodiscard
|
||||
function mqueue.new()
|
||||
local queue = {}
|
||||
|
||||
local insert = table.insert
|
||||
local remove = table.remove
|
||||
|
||||
---@class queue_item
|
||||
---@field qtype MQ_TYPE
|
||||
---@field message any
|
||||
|
||||
---@class queue_data
|
||||
---@field key any
|
||||
---@field val any
|
||||
|
||||
---@class mqueue
|
||||
local public = {}
|
||||
|
||||
@@ -48,28 +48,20 @@ function mqueue.new()
|
||||
-- push a new item onto the queue
|
||||
---@param qtype MQ_TYPE
|
||||
---@param message any
|
||||
local function _push(qtype, message)
|
||||
insert(queue, { qtype = qtype, message = message })
|
||||
end
|
||||
local function _push(qtype, message) insert(queue, { qtype = qtype, message = message }) end
|
||||
|
||||
-- push a command onto the queue
|
||||
---@param message any
|
||||
function public.push_command(message)
|
||||
_push(TYPE.COMMAND, message)
|
||||
end
|
||||
function public.push_command(message) _push(TYPE.COMMAND, message) end
|
||||
|
||||
-- push data onto the queue
|
||||
---@param key any
|
||||
---@param value any
|
||||
function public.push_data(key, value)
|
||||
_push(TYPE.DATA, { key = key, val = value })
|
||||
end
|
||||
function public.push_data(key, value) _push(TYPE.DATA, { key = key, val = value }) end
|
||||
|
||||
-- push a packet onto the queue
|
||||
---@param packet packet|frame
|
||||
function public.push_packet(packet)
|
||||
_push(TYPE.PACKET, packet)
|
||||
end
|
||||
function public.push_packet(packet) _push(TYPE.PACKET, packet) end
|
||||
|
||||
-- get an item off the queue
|
||||
---@nodiscard
|
||||
@@ -77,9 +69,7 @@ function mqueue.new()
|
||||
function public.pop()
|
||||
if #queue > 0 then
|
||||
return remove(queue, 1)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
else return nil end
|
||||
end
|
||||
|
||||
return public
|
||||
|
||||
Reference in New Issue
Block a user