Frobby 0.10.0
Loading...
Searching...
No Matches
ObjectCache< T > Class Template Reference

#include <ObjectCache.h>

Public Member Functions

unique_ptr< T > newObject ()
template<class S>
unique_ptr< T > newObjectCopy (const S &copyOf)
template<class S>
void freeObject (unique_ptr< S > object)

Detailed Description

template<class T>
class ObjectCache< T >

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.

Member Function Documentation

◆ freeObject()

template<class T>
template<class S>
void ObjectCache< T >::freeObject ( unique_ptr< S > object)

Insert an object into the cache.

◆ newObject()

template<class T>
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().

◆ newObjectCopy()

template<class T>
template<class S>
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.


The documentation for this class was generated from the following file: