Sirikata
|
Critical to the functioning of CacheLayer--makes decisions which pieces of data to keep and which to throw out. More...
#include <CachePolicy.hpp>
Classes | |
struct | Data |
Public Member Functions | |
CachePolicy (cache_usize_type allocatedSpace, float maxSizePct) | |
virtual | ~CachePolicy () |
Virtual destructor since children will allocate class members. | |
virtual void | use (const Fingerprint &id, Data *data, cache_usize_type size)=0 |
Marks the entry as used. | |
virtual void | useAndUpdate (const Fingerprint &id, Data *data, cache_usize_type oldsize, cache_usize_type newsize)=0 |
Marks the entry as used, and update the space usage. | |
virtual void | destroy (const Fingerprint &id, Data *data, cache_usize_type size)=0 |
Deletes the opaque data (and anything other corresponding info) | |
virtual Data * | create (const Fingerprint &id, cache_usize_type size)=0 |
Allocates opaque data (and anything other corresponding info) At this point, the allocation must not fail. | |
virtual bool | cachable (cache_usize_type requiredSpace) |
Allocates a certain number of bytes for use in a new cache entry. | |
virtual bool | nextItem (cache_usize_type requiredSpace, Fingerprint &myprint)=0 |
Protected Member Functions | |
void | updateSpace (cache_usize_type oldsize, cache_usize_type newsize) |
Protected Attributes | |
cache_usize_type | mTotalSize |
float | mMaxSizePct |
cache_ssize_type | mFreeSpace |
Critical to the functioning of CacheLayer--makes decisions which pieces of data to keep and which to throw out.
Sirikata::Transfer::CachePolicy::CachePolicy | ( | cache_usize_type | allocatedSpace, |
float | maxSizePct | ||
) | [inline] |
virtual Sirikata::Transfer::CachePolicy::~CachePolicy | ( | ) | [inline, virtual] |
Virtual destructor since children will allocate class members.
virtual bool Sirikata::Transfer::CachePolicy::cachable | ( | cache_usize_type | requiredSpace | ) | [inline, virtual] |
Allocates a certain number of bytes for use in a new cache entry.
requiredSpace | the amount of space this single entry needs |
References Sirikata::Logging::insane, mFreeSpace, mMaxSizePct, mTotalSize, and SILOG.
Referenced by Sirikata::Transfer::CacheMap::alloc().
virtual Data* Sirikata::Transfer::CachePolicy::create | ( | const Fingerprint & | id, |
cache_usize_type | size | ||
) | [pure virtual] |
Allocates opaque data (and anything other corresponding info) At this point, the allocation must not fail.
It is up to the CacheLayer to respect the decision from allocateSpace().
id | The FileId corresponding to the data. |
size | The amount of space allocated (should be the same as was earlier passed to allocateSpace). |
Implemented in Sirikata::Transfer::LRUPolicy.
Referenced by Sirikata::Transfer::CacheMap::write_iterator::insert().
virtual void Sirikata::Transfer::CachePolicy::destroy | ( | const Fingerprint & | id, |
Data * | data, | ||
cache_usize_type | size | ||
) | [pure virtual] |
Deletes the opaque data (and anything other corresponding info)
id | The FileId corresponding to the data. |
data | The opaque data corresponding to this policy. |
size | The size of the file data. |
Implemented in Sirikata::Transfer::LRUPolicy.
Referenced by Sirikata::Transfer::CacheMap::write_iterator::erase(), and Sirikata::Transfer::CacheMap::write_iterator::eraseAll().
virtual bool Sirikata::Transfer::CachePolicy::nextItem | ( | cache_usize_type | requiredSpace, |
Fingerprint & | myprint | ||
) | [pure virtual] |
Implemented in Sirikata::Transfer::LRUPolicy.
Referenced by Sirikata::Transfer::CacheMap::alloc().
void Sirikata::Transfer::CachePolicy::updateSpace | ( | cache_usize_type | oldsize, |
cache_usize_type | newsize | ||
) | [inline, protected] |
References Sirikata::Logging::insane, mFreeSpace, and SILOG.
Referenced by Sirikata::Transfer::LRUPolicy::create(), Sirikata::Transfer::LRUPolicy::destroy(), and Sirikata::Transfer::LRUPolicy::useAndUpdate().
virtual void Sirikata::Transfer::CachePolicy::use | ( | const Fingerprint & | id, |
Data * | data, | ||
cache_usize_type | size | ||
) | [pure virtual] |
Marks the entry as used.
id | The FileId corresponding to the data. |
data | The opaque data corresponding to this policy. |
size | The size of the file data. |
Implemented in Sirikata::Transfer::LRUPolicy.
Referenced by Sirikata::Transfer::CacheMap::write_iterator::use(), and Sirikata::Transfer::CacheMap::read_iterator::use().
virtual void Sirikata::Transfer::CachePolicy::useAndUpdate | ( | const Fingerprint & | id, |
Data * | data, | ||
cache_usize_type | oldsize, | ||
cache_usize_type | newsize | ||
) | [pure virtual] |
Marks the entry as used, and update the space usage.
id | The FileId corresponding to the data. |
data | The opaque data corresponding to this policy. |
oldsize | The previous size of the data. |
newsize | The new size of the data. |
Implemented in Sirikata::Transfer::LRUPolicy.
Referenced by Sirikata::Transfer::CacheMap::write_iterator::update().
float Sirikata::Transfer::CachePolicy::mMaxSizePct [protected] |
Referenced by cachable().
Referenced by cachable().