#include <cache.h>
Public Member Functions | |
virtual void | abort () |
Cache (uint64_t _capacity=INT_MAX) | |
uint64_t | capacity () |
void | flush () |
template<class FUNCTOR > | |
void | flush (FUNCTOR functor) |
bool | newData () |
return true if the cache is waiting for priority to change | |
void | setCapacity (uint64_t c) |
void | setInputCache (Provider< Token > *p) |
uint64_t | size () |
virtual | ~Cache () |
Public Attributes | |
void(* | callback )(void *data) |
callback for new_data | |
bool | final |
true if this is the last cache (the one we use the data from) | |
Provider< Token > * | input |
data is fetched from here | |
mt::atomicInt | new_data |
keeps track of changes (if 1 then something was loaded or dropped | |
bool | quit |
std::vector< Transfer< Token > * > | transfers |
threads running over cache... | |
Protected Member Functions | |
virtual void | begin () |
make sure the get function do not access token after abort is returned. | |
virtual int | drop (Token *token)=0 |
return amount removed | |
virtual void | end () |
called in as last thing in run() | |
virtual int | get (Token *token)=0 |
returns amount of space used in cache -1 for failed transfer | |
bool | load () |
should be protected | |
virtual void | middle () |
void | run () |
[should be protected] | |
virtual int | size (Token *token)=0 |
return the space used in the cache by the loaded resource | |
bool | unload () |
Protected Attributes | |
uint64_t | s_curr |
current space used | |
uint64_t | s_max |
max space available |
vcg::Cache< Token >::Cache | ( | uint64_t | _capacity = INT_MAX | ) | [inline] |
virtual vcg::Cache< Token >::~Cache | ( | ) | [inline, virtual] |
virtual void vcg::Cache< Token >::abort | ( | ) | [inline, virtual] |
virtual void vcg::Cache< Token >::begin | ( | ) | [inline, protected, virtual] |
uint64_t vcg::Cache< Token >::capacity | ( | ) | [inline] |
virtual int vcg::Cache< Token >::drop | ( | Token * | token | ) | [protected, pure virtual] |
return amount removed
virtual void vcg::Cache< Token >::end | ( | ) | [inline, protected, virtual] |
void vcg::Cache< Token >::flush | ( | ) | [inline] |
void vcg::Cache< Token >::flush | ( | FUNCTOR | functor | ) | [inline] |
empty the cache. Make sure no resource is locked before calling this. Require pause or stop before. Ensure there no locked item
Reimplemented from vcg::Provider< Token >.
virtual int vcg::Cache< Token >::get | ( | Token * | token | ) | [protected, pure virtual] |
returns amount of space used in cache -1 for failed transfer
bool vcg::Cache< Token >::load | ( | ) | [inline, protected] |
virtual void vcg::Cache< Token >::middle | ( | ) | [inline, protected, virtual] |
bool vcg::Cache< Token >::newData | ( | ) | [inline] |
void vcg::Cache< Token >::run | ( | void | ) | [inline, protected, virtual] |
void vcg::Cache< Token >::setCapacity | ( | uint64_t | c | ) | [inline] |
void vcg::Cache< Token >::setInputCache | ( | Provider< Token > * | p | ) | [inline] |
uint64_t vcg::Cache< Token >::size | ( | ) | [inline] |
virtual int vcg::Cache< Token >::size | ( | Token * | token | ) | [protected, pure virtual] |
return the space used in the cache by the loaded resource
bool vcg::Cache< Token >::unload | ( | ) | [inline, protected] |
Checks wether we need to make room in the cache because of: size() - sizeof(lowest priority item) > capacity()
void(* vcg::Cache< Token >::callback)(void *data) |
bool vcg::Cache< Token >::final |
Provider<Token>* vcg::Cache< Token >::input |
mt::atomicInt vcg::Cache< Token >::new_data |
bool vcg::Cache< Token >::quit |
uint64_t vcg::Cache< Token >::s_curr [protected] |
uint64_t vcg::Cache< Token >::s_max [protected] |
std::vector<Transfer<Token> *> vcg::Cache< Token >::transfers |