mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-19 21:10:19 +02:00
24 lines
374 B
Lua
24 lines
374 B
Lua
|
local Public = {}
|
||
|
Public.__index = Public
|
||
|
|
||
|
function Public:new(limit)
|
||
|
return setmetatable({ count = limit, limit = limit }, self)
|
||
|
end
|
||
|
|
||
|
function Public:acquire()
|
||
|
if self.count > 0 then
|
||
|
self.count = self.count - 1
|
||
|
return true
|
||
|
else
|
||
|
return false
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function Public:release()
|
||
|
if self.count < self.limit then
|
||
|
self.count = self.count + 1
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return Public
|