Files
module-fastwebcore/target/fastweb/mutex.lua
2026-03-31 16:00:38 +08:00

42 lines
626 B
Lua

-- mutex.lua
local mutex = {}
mutex.__index = mutex
--[[
构造函数,创建一个新的 fw_mutex 对象
@return 返回一个新的 fw_mutex 对象
]]
function mutex.new()
local instance = setmetatable({}, mutex)
instance.module = fw_mutex.new()
return instance
end
--[[
加锁
]]
function mutex:lock()
self.module:lock()
end
--[[
释放锁
]]
function mutex:unlock()
self.module:unlock()
end
--[[
尝试加锁
@return 是否成功加锁
]]
function mutex:try_lock()
return self.module:try_lock()
end
function mutex:self()
return self.module:self()
end
return mutex