-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpools.lua
More file actions
35 lines (31 loc) · 722 Bytes
/
pools.lua
File metadata and controls
35 lines (31 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local _, ns = ...
local lib
if ns.LibEditMode then
lib = ns.LibEditMode
else
local MINOR, prevMinor = 15
lib, prevMinor = LibStub('LibEditMode')
if prevMinor > MINOR then
return
end
end
local Acquire = CreateUnsecuredObjectPool().Acquire
local function acquire(self, parent)
local obj, new = Acquire(self)
obj:SetParent(parent)
return obj, new
end
local pools = {}
function lib.internal:CreatePool(kind, creationFunc, resetterFunc)
local pool = CreateUnsecuredObjectPool(creationFunc, resetterFunc)
pool.Acquire = acquire
pools[kind] = pool
end
function lib.internal:GetPool(kind)
return pools[kind]
end
function lib.internal:ReleaseAllPools()
for _, pool in next, pools do
pool:ReleaseAll()
end
end