
---@class copas_queue_options*
---@field name? string Queue name.
---@field workers? integer worker quantity.
---@field handler? function worker handler。

---@class copas_queue_module*
---@type copas_queue_module*
local M = {}

---@class copas_queue_object*
local copas_queue_object = {}

--- Create queue.
---@param opts? copas_queue_options* options.
---@return copas_queue_object* queue Queue object.
function M.new(opts) end

--- Push the task.
---@param item any Task.
---@return boolean|nil ok Whether it is successful or not.
---@return string? errMsg error message.
function copas_queue_object:push(item) end

--- Pop up tasks.
---@param timeout? number Timeout seconds.
---@return any item Task.
---@return string? errMsg error message.
function copas_queue_object:pop(timeout) end

--- Get the queue length.
---@return integer size length.
function copas_queue_object:get_size() end

--- Stop the queue.
---@return boolean ok Whether it is successful or not.
function copas_queue_object:stop() end

--- Wait for the queue to end.
---@param timeout? number Timeout seconds.
---@param no_destroy_on_timeout? boolean Whether it will not be destroyed after timeout.
---@return boolean|nil ok Whether it is successful or not.
---@return string? errMsg error message.
function copas_queue_object:finish(timeout, no_destroy_on_timeout) end

--- Add workers.
---@param worker function worker function.
---@return thread co worker coroutine。
function copas_queue_object:add_worker(worker) end

--- Get the worker list.
---@return thread[] workers worker list.
function copas_queue_object:get_workers() end

--- Destroy the queue.
function copas_queue_object:destroy() end

return M
