Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

Global Value Cache

 

Global Value Cache is a centralized mechanism to cache data. Items in the cache are of Value type. Global Value Cache adjusts its size based on current system memory consumption.

 

Function List

 

Value MakeValue(ValueMaker& m)

Requests a Value. The Value is defined by instance of class derived from ValueMaker, which is class with two virtual methods:

 

virtual String Key() const;

virtual int Make(T& object) const;

 

Key should return unique identifier for Value requested with ValueMaker derived class. Note that the type of ValueMaker derived class becomes a part of the key, so it is not necessary to add any info about the ValueMaker into the key. Make then creates the corresponding Value and returns the approximate memory consumption needed to store that Value. MakeValue first checks whether Value corresponding to given ValueMaker and Key are in the cache, if yes then it returns Value from the cache, otherwise calls ValueMaker::Make to obtain the Value and stores it to the cache.

 


 

bool IsValueCacheActive()

Returns true if it is still possible to use Value Cache. This special function is intended to solve destruction conflicts at the program exit.

 


 

void AdjustValueCache()

Adjusts the size of cache based on system memory available. The process is driven by parameters that can be set by SetupValueCache. Note that CtrlCore (U++ GUI) normally calls this function after processing every GUI event.

 


 

void ShrinkValueCache()

Maintains the size of cache based on limit computed in the last AdjustValueCache call.

 


 

void SetupValueCache(int limit_low, int limit_high, double ratio)

Setups parameters that govern the cache size. limit_low is low limit - cache will never be reduced if its consumption is bellow this limit (default is 4MB). limit_high is upper limit - cache size will never grow beyond this limit (default is 2GB). ratio defines how much available system physical memory can be dedicated to the cache, default is 12.5%.

 


 

template <class Pint ValueCacheRemove(P what)

Removes all Values from the cache that satisfy what predicate.

 


 

template <class Pint ValueCacheRemoveOne(P what)

Removes one Value from the cache that satisfy what predicate (simply removes the first one that it finds).

 


 

template <class Pvoid ValueCacheAdjustSize(P getsize)

Adjusts size information. getsize should return the memory size needed to store Value passed as parameter or it can return negative number to signal that the size has not changed. This is very specific function basically only needed to support PaintOnly Images.

 

Last edit by cxl on 06/11/2020. Do you want to contribute?. T++