Generic Pool to re-use objects of a certain type (TType) that optionally match a certain property or set of properties (TInfo).
More...
Inherits IDisposable.
|
abstract TType | createObject (TInfo info) |
|
abstract void | destroyObject (TType obj) |
|
abstract bool | infosMatch (TInfo i0, TInfo i1) |
|
|
int | capacity |
|
TInfo | info |
|
int | pos |
|
string | name |
|
|
TInfo | Info [get] |
| The property (info) that objects in this Pool must match. More...
|
|
Generic Pool to re-use objects of a certain type (TType) that optionally match a certain property or set of properties (TInfo).
- Template Parameters
-
TType | Object type. |
TInfo | Type of parameter used to check 2 objects identity (like integral length of array). |
Create a new ObjectPool instance. Does not call Init().
- Parameters
-
capacity | Capacity (size) of the object pool. |
name | Name of the object pool. |
ObjectPool |
( |
int |
capacity, |
|
|
string |
name, |
|
|
TInfo |
info |
|
) |
| |
Create a new ObjectPool instance with the given info structure. Calls Init().
- Parameters
-
capacity | Capacity (size) of the object pool. |
name | Name of the object pool. |
info | Info about this Pool's objects. |
TType AcquireOrCreate |
( |
| ) |
|
Acquire an existing object, or create a new one if none are available.
If it fails to get one from the pool, this will create from the info given in this pool's constructor.
TType AcquireOrCreate |
( |
TInfo |
info | ) |
|
Acquire an existing object (if info matches), or create a new one from the passed info.
- Parameters
-
info | Info structure to match, or create a new object with. |
(Re-)Initializes this ObjectPool.
If there are objects available in this Pool, they will be destroyed. Allocates (Capacity) new Objects.
- Parameters
-
info | Info about this Pool's objects. |
virtual bool Release |
( |
TType |
obj, |
|
|
TInfo |
objInfo |
|
) |
| |
|
virtual |
Returns object to pool.
- Parameters
-
obj | The object to return to the pool. |
objInfo | The info structure about obj. |
obj is returned to the pool only if objInfo matches this pool's info. Else, it is destroyed.
virtual bool Release |
( |
TType |
obj | ) |
|
|
virtual |
Returns object to pool, or destroys it if the pool is full.
- Parameters
-
obj | The object to return to the pool. |
The property (info) that objects in this Pool must match.