VISH
0.2
|
A domain for objects which may be cached. More...
#include </home/werner/origo/vish/memcore/Cacheable.hpp>
A domain for objects which may be cached.
Cacheable objects must be derived from this base class such that a WeakPtr<Cacheable> may point to such object and becomes notified when the object is removed. Any child classes must overload the virtual memsize() to tell the Cache class how costly the storage of objects of this kind is. Note that the memsize() does not necessarily need to be given in bytes, any other unit is acceptable as long as the same is used consistently for all objects that are assigned to the same Cache object.
void MemCore::Cacheable::adjustCacheableSize | ( | memsize_t | memDiff | ) | [protected] |
In case this object changes its size after insertion to the CacheQueue, call this function to adjust.
Alternatively, the cachequeue's memsize could be recomputed, but is much more effortsome.
void MemCore::Cacheable::DeferredConstructor | ( | ) | [virtual] |
A virtual function that is called on the first strong referencing of a Cacheable object.
This (usually) is not possible within the constructor, so it may be assumed that the object has been completely constructed. The implementation of this function may thus perform operations on the object which should be done automatically when objects of this kind are created, but they may be aware of the full object status which is not possible in the constructor.
bool MemCore::Cacheable::markAsUsed | ( | ) |
Mark this data object as being recently used.
This is the same as touching the data, but touch() is also used in the Ageable class, so here we use another name to avoid confusion.
int MemCore::Cacheable::NumberOfListEntries | ( | ) | const |
Count the number of entries here.
Never call this function, it is maximally slow.
void MemCore::Cacheable::PreDestructor | ( | ) |
This class uses a predestructor to remove itself's size from the cache queue.
This could not be done in the "official" destructor itself because it depends on the call of the virtual function memsize() which is no longer available in the destructor.
void MemCore::Cacheable::push_back | ( | CacheQueue & | Q | ) |
Put the current item onto the BACK of the given cache queue.
The memory sizes of the current and new cache queues will be adjusted.
void MemCore::Cacheable::push_front | ( | CacheQueue & | Q | ) |
Put the current item onto the FRONT of the given cache queue.
The memory sizes of the current and new cache queues will be adjusted.