| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- -- 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
|