PGRData/Script/matrix/binary/ReaderPool.lua

22 lines
370 B
Lua
Raw Permalink Normal View History

2024-09-01 20:49:41 +00:00
ReaderPool = ReaderPool or {}
local Reader = require("Binary/Reader")
local pool = {}
function ReaderPool.GetReader()
if #pool <= 0 then
return Reader.New()
else
return table.remove(pool)
end
end
function ReaderPool.ReleaseReader(reader)
reader:Close()
table.insert(pool, reader)
end
function ReaderPool.Clear()
pool = {}
end