Appearance
ObjectPool
Inherits: Class
Methods
Acquire
lua
function ObjectPool:Acquire()
-> <T>, booleanAcquires an object from the pool, creating one if necessary.
Returns:
| Name | Type | Description |
|---|---|---|
| `` | <T> | |
isNew | boolean |
EnumerateActive
lua
function ObjectPool:EnumerateActive()
-> fun():TReturns an iterator over all currently active objects in the pool.
Returns:
| Type | Description |
|---|---|
fun():T |
EnumerateInactive
lua
function ObjectPool:EnumerateInactive()
-> fun():TReturns an iterator over all currently inactive objects in the pool.
Returns:
| Type | Description |
|---|---|
fun():T |
Get
lua
function ObjectPool:Get()
-> <T>Either returns a recycled instance of the object or creates a new one as applicable.
Returns:
| Type | Description |
|---|---|
<T> |
GetNumActive
lua
function ObjectPool:GetNumActive()
-> numberReturns the number of currently active objects in the pool.
Returns:
| Type | Description |
|---|---|
number |
Recycle
lua
function ObjectPool:Recycle(obj)Recycles an instance of the object back into the pool.
Parameters:
| Name | Type | Description |
|---|---|---|
obj | T | The object to recycle |
Release
lua
function ObjectPool:Release(obj)Releases the given object back into the pool.
Parameters:
| Name | Type | Description |
|---|---|---|
obj | T |
ReleaseAll
lua
function ObjectPool:ReleaseAll()Releases all active objects back into the pool.
_GetDebugInfo
lua
function ObjectPool:_GetDebugInfo()__init
lua
function ObjectPool:__init(createFunc, extraStackOffset)Parameters:
| Name | Type | Description |
|---|---|---|
createFunc | `` | |
extraStackOffset | `` |
Functions
EnableLeakDebug
lua
function ObjectPool.EnableLeakDebug()Enables leak debugging.
GetDebugInfo
lua
function ObjectPool.GetDebugInfo()
-> table<string, ObjectPoolDebugInfo>Gets debug information which represents the current state of all the created object pools
Returns:
| Type | Description |
|---|---|
table<string, ObjectPoolDebugInfo> |
New
lua
function ObjectPool.New(name, createFunc, extraStackOffset)
-> ObjectPoolCreate a new object pool.
Parameters:
| Name | Type | Description |
|---|---|---|
name | string | The name of the object pool for debug purposes |
createFunc | fun(): T | T | The function which is called to create a new object, or a Class |
extraStackOffset | number | The extra stack offset for tracking where objects are being used from or nil to disable stack info |
Returns:
| Type | Description |
|---|---|
ObjectPool |