Photon Voice: ObjectPool< TType, TInfo > Class Template Reference
From Photon Voice
|
Photon Voice
v2.7
|
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.
Public Member Functions | |
| ObjectPool (int capacity, string name) | |
| Create a new ObjectPool instance. Does not call Init(). More... | |
| ObjectPool (int capacity, string name, TInfo info) | |
| Create a new ObjectPool instance with the given info structure. Calls Init(). More... | |
| void | Init (TInfo info) |
| (Re-)Initializes this ObjectPool. More... | |
| TType | AcquireOrCreate () |
| Acquire an existing object, or create a new one if none are available. More... | |
| TType | AcquireOrCreate (TInfo info) |
| Acquire an existing object (if info matches), or create a new one from the passed info. More... | |
| virtual bool | Release (TType obj, TInfo objInfo) |
| Returns object to pool. More... | |
| virtual bool | Release (TType obj) |
| Returns object to pool, or destroys it if the pool is full. More... | |
| void | Dispose () |
| Free resources assoicated with this ObjectPool More... | |
Protected Member Functions | |
| abstract TType | createObject (TInfo info) |
| abstract void | destroyObject (TType obj) |
| abstract bool | infosMatch (TInfo i0, TInfo i1) |
Protected Attributes | |
| int | capacity |
| TInfo | info |
| int | pos |
| string | name |
Properties | |
| TInfo | Info [get] |
| The property (info) that objects in this Pool must match. More... | |
Detailed Description
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).
Constructor & Destructor Documentation
| ObjectPool | ( | int | capacity, |
| string | name | ||
| ) |
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.
Member Function Documentation
| 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.
| void Dispose | ( | ) |
Free resources assoicated with this ObjectPool
| void Init | ( | TInfo | info | ) |
(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 |
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 |
Returns object to pool, or destroys it if the pool is full.
- Parameters
-
obj The object to return to the pool.
Property Documentation
|
get |
The property (info) that objects in this Pool must match.