wowpedia
Main Menu


FrameXML Funcs
FrameXML Docs
These functions are implemented in :Acquire FrameXML/Pools.lua.

Furnishes a widget, or returns it to the object pool.

widget = pool:Acquire()
success = pool:Release(widget)
pool:ReleaseAll()

Arguments / Returns

widget
UIObject - Furnished by Acquire() or returned by Release().
success
boolean - Returned by Release() as true if returning the widget to the pool, or false otherwise (the widget is not even part of the pool, or was previously returned).

Details

Example

-- initialize the pool
local function creationFunc()
	return CreateFrame("Frame")
end
local function resetterFunc(__, frame)
	frame:Hide()
end
local pool = CreateObjectPool(creationFunc, resetterFunc)

-- Request a frame
local frame = pool:Acquire()
frame:Show()

-- Return the frame when it is no longer required
pool:Release(frame)

-- Request a frame again
local frame = pool:Acquire()  -- could be a different frame if others were acquired/released in the interim
frame:Show() -- cancels Hide() in resetterFunc

Patch changes

References

 
  1. ^ 2018-07-16, Pools.lua, version 8.0.1.27101, near line 104, archived at Townlong-Yak
  2. ^ 2017-03-28, Pools.lua, version 7.3.0.23835, near line 75, archived at Townlong-Yak