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

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

--- Create a semaphore.
---@param max? integer Maximum quantity.
---@param start? integer Initial quantity.
---@param seconds? number Default number of seconds to wait.
---@return copas_semaphore_object* semaphore Semaphore object.
function M.new(max, start, seconds) end

--- Return the semaphore.
---@param given? integer Quantity, default is 1.
---@return boolean|nil ok Whether it is successful or not.
---@return string? errMsg error message.
function copas_semaphore_object:give(given) end

--- Get the semaphore.
---@param requested? integer Quantity, default is 1.
---@param timeout? number Timeout seconds.
---@return boolean|nil ok Whether it is successful or not.
---@return string? errMsg error message.
function copas_semaphore_object:take(requested, timeout) end

--- Current available quantity.
---@return integer count quantity.
function copas_semaphore_object:get_count() end

--- Current waiting quantity.
---@return integer waitCount Waiting quantity.
function copas_semaphore_object:get_wait() end

--- Destroy the semaphore.
function copas_semaphore_object:destroy() end

return M
