|
Frobby 0.10.0
|
#include <ObjectCache.h>
Public Member Functions | |
| unique_ptr< T > | newObject () |
| template<class S> | |
| unique_ptr< T > | newObjectCopy (const S ©Of) |
| template<class S> | |
| void | freeObject (unique_ptr< S > object) |
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.
Insert an object into the cache.
| unique_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().
| unique_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.