Frobby
0.9.5
|
An ObjectCache keeps a cache of previously-used objects to cut down on the number of allocations. More...
#include <ObjectCache.h>
Public Member Functions | |
ObjectCache () | |
auto_ptr< T > | newObject () |
Returns an object. More... | |
template<class S > | |
auto_ptr< T > | newObjectCopy (const S ©Of) |
Returns a copy of copyOf. More... | |
template<class S > | |
void | freeObject (auto_ptr< S > object) |
Insert an object into the cache. More... | |
Private Attributes | |
vector< T * > | _cache |
ElementDeleter< vector< T * > > | _cacheDeleter |
An ObjectCache keeps a cache of previously-used objects to cut down on the number of allocations.
The cache accepts unused objects that would otherwise be due for deallocation, and returns them in place of a new object when asked for one. If the cache is asked for an object and it is not storing any, it will transparently allocate one to satisfy the request. Stored objects are not freed until the cache is destructed.
Definition at line 35 of file ObjectCache.h.
|
inline |
Definition at line 63 of file ObjectCache.h.
Insert an object into the cache.
Definition at line 90 of file ObjectCache.h.
auto_ptr< T > ObjectCache< T >::newObject |
Returns an object.
The new object is constructed using the standard constructor, or it is an object previously passed to freeObject().
Definition at line 69 of file ObjectCache.h.
auto_ptr< T > ObjectCache< T >::newObjectCopy | ( | const S & | copyOf | ) |
Returns a copy of copyOf.
The new object is constructed using the copy constructor, or it is an object previously passed to freeObject() that has copyOf assigned to it.
Definition at line 79 of file ObjectCache.h.
|
private |
Definition at line 56 of file ObjectCache.h.
|
private |
Definition at line 57 of file ObjectCache.h.