Once I understood what this frame pool did, I created a very simple version I use in Decliner for generating OnUpdate responses to some filters. This way, I don't need several dedicated OnUpdate frames, just a dynamic pool that uses the first unused frame or creates a new one that adds to the pool when finished. Blizzard's way is definitely more sophisticated and made for different scenarios, but if you just need a disposable OnUpdate frame with one piece of data included in the frame, you could try what I did.
Lua Code:
local pool={}
function f.pool(t,i)
if i then
pool[i]:SetScript('OnUpdate',nil)
pool[i].t=nil
return
end -- function was called with an index, terminate frame at that index
for i=1,#pool do
if pool[i] and not pool[i].t then
pool[i].t={i=i,t=t}
return i
end -- loop through frames to find an unused one and return the index, putting "t" into the frame
end
insert(pool,CreateFrame('frame'))
i=#pool
pool[i].t={i=i,t=t}
return i -- no unused frames found, generate a new one and return its index, also putting "t" into the frame
end
An example of usage is the following response to blocked guild invites:
Lua Code:
pool[f.pool((GetCVar('Sound_EnableSFX')))]:SetScript('OnUpdate',function(self)
SetCVar('Sound_EnableSFX',self.t.t)
f.pool('',self.t.i)
end)
SetCVar('Sound_EnableSFX','0')
This calls a frame directly from the pool table, while getting the index from f.pool's return and putting the current SFX setting into the "t" key of the frame. Then I turn off SFX. Once the OnUpdate fires a frame later, reset SFX and release the frame using its index stored in the "i" key.
This completely blocks the "level up" sound when someone invites you to a guild.
I'm sure there's a cleaner way to do what I did, but it works for me.