#include <FlyWeightPool.h>
Collaboration diagram for syn::FlyWeightPool:
Public Methods | |
FlyWeightPool () | |
~FlyWeightPool () | |
void | setAutoGrow (bool grow) |
bool | autoGrow () const |
void | acquire () const |
bool | tryAcquire () const |
void | release () const |
void | resize (unsigned int s) |
resize of flyweight pool is safe: i.e. More... | |
unsigned int | size () const |
return the total number of objects this flyweight pool is managing. More... | |
int | available () const |
number of flyweights available. More... | |
bool | empty () const |
check to see if the pool is empty (then take() would fail). More... | |
void | take (type *&t) |
take an item from the pool use this function like you would use "new" if autoGrow() == false then you must check empty() before takeing. More... | |
void | putback (type *t) |
put back an item to the pool use this function like you would use "delete". More... |
Implements the flyweight pattern as described in "Design Patterns" You should think of the FlyWeightPool<_T> as a factory for objects of type _T. Use take/putback instead of new/delete for all objects of type _T.
flyweight pool rules: 1.) by default, and when autoGrow() == false, this is a fixed size pool of flyweights with no auto adjustment, when items are gone, they are gone, check empty() before taking any! 2.) pool is autogrowable if you setAutoGrow( true ), take() is then safe to call as many times as you need. 3.) resize of flyweight pool is safe: i.e. doesn't invalidate pointers 4.) all items must be checked back in before destroying this pool.
Definition at line 60 of file FlyWeightPool.h.
|
Definition at line 63 of file FlyWeightPool.h. |
|
Definition at line 69 of file FlyWeightPool.h. |
|
Definition at line 83 of file FlyWeightPool.h. Referenced by syn::SampleBufferRepos::SampleBufferRepos().
|
|
Definition at line 84 of file FlyWeightPool.h. |
|
Definition at line 91 of file FlyWeightPool.h. Referenced by FlyWeightPool(), putback(), resize(), take(), and ~FlyWeightPool().
|
|
Definition at line 92 of file FlyWeightPool.h. |
|
Definition at line 93 of file FlyWeightPool.h. Referenced by FlyWeightPool(), putback(), resize(), take(), and ~FlyWeightPool().
|
|
resize of flyweight pool is safe: i.e. doesn't invalidate pointers Definition at line 96 of file FlyWeightPool.h. |
|
return the total number of objects this flyweight pool is managing.
Definition at line 106 of file FlyWeightPool.h. |
|
number of flyweights available.
Definition at line 109 of file FlyWeightPool.h. |
|
check to see if the pool is empty (then take() would fail).
Definition at line 112 of file FlyWeightPool.h. Referenced by take().
|
|
take an item from the pool use this function like you would use "new" if autoGrow() == false then you must check empty() before takeing.
Definition at line 118 of file FlyWeightPool.h. Referenced by syn::SampleBufferRepos::take().
|
|
put back an item to the pool use this function like you would use "delete".
Definition at line 135 of file FlyWeightPool.h. Referenced by syn::SampleBufferRepos::putback().
|