Cache is a helper class used to cache objects. More...
#include <InstantIO/Cache.h>
Public Member Functions | |
~Cache () | |
Destroys the Cache object. | |
RefCtr< T > * | acquire () |
Acquires a new object. | |
void | release (RefCtr< T > *value) |
Releases an object. | |
Cache () | |
Creates a new Cache object. | |
Static Public Member Functions | |
static Cache< T > & | the () |
Returns the single instance of the Cache class Cache is a singleton, i.e. |
Cache is a helper class used to cache objects.
InstantIO::Cache< T >::~Cache | ( | ) | [inline] |
Destroys the Cache object.
Automatically destroys all objects stored in the cache. Throws an exception when there is any object still in use by the application.
InstantIO::Cache< T >::Cache | ( | ) | [inline] |
Creates a new Cache object.
The Constructor is protected because you are not allowed to create Cache objects. Cache is a singleton, i.e. only one instance of Cache exists. You can access this instance by calling the the method.
static Cache<T>& InstantIO::Cache< T >::the | ( | ) | [inline, static] |
Returns the single instance of the Cache class Cache is a singleton, i.e.
only one instance of this class exists. You can access this instance by calling this method.
RefCtr<T>* InstantIO::Cache< T >::acquire | ( | ) | [inline] |
Acquires a new object.
Call this method when you need a new object. When there is an unused object available in the cache, returns this object. Otherwise, creates a new object. Because you may get an object already used before, you have to initialize the object! Call the release method when you do not need the object any more.
void InstantIO::Cache< T >::release | ( | RefCtr< T > * | value | ) | [inline] |
Releases an object.
Call this method when you do not need an object you got from the acquire method any more. The object is inserted into the cache and reused when you call acquire again. Do not try to access the object after calling this method!
value | The object |