Sirikata
|
Simple LRU policy--does not do any ordering by size. More...
#include <LRUPolicy.hpp>
Classes | |
struct | LRUData |
Public Member Functions | |
LRUPolicy (cache_usize_type allocatedSpace, float maxSizePct=0.5) | |
virtual void | use (const Fingerprint &id, Data *data, cache_usize_type size) |
Marks the entry as used. | |
virtual void | useAndUpdate (const Fingerprint &id, Data *data, cache_usize_type oldsize, cache_usize_type newsize) |
Marks the entry as used, and update the space usage. | |
virtual void | destroy (const Fingerprint &id, Data *data, cache_usize_type size) |
Deletes the opaque data (and anything other corresponding info) | |
virtual Data * | create (const Fingerprint &id, cache_usize_type size) |
Allocates opaque data (and anything other corresponding info) At this point, the allocation must not fail. | |
virtual bool | nextItem (cache_usize_type requiredSpace, Fingerprint &myprint) |
Private Types | |
typedef Fingerprint | LRUElement |
typedef std::list< LRUElement > | LRUList |
Private Attributes | |
LRUList | mLeastUsed |
Simple LRU policy--does not do any ordering by size.
typedef Fingerprint Sirikata::Transfer::LRUPolicy::LRUElement [private] |
typedef std::list<LRUElement> Sirikata::Transfer::LRUPolicy::LRUList [private] |
Sirikata::Transfer::LRUPolicy::LRUPolicy | ( | cache_usize_type | allocatedSpace, |
float | maxSizePct = 0.5 |
||
) | [inline] |
virtual Data* Sirikata::Transfer::LRUPolicy::create | ( | const Fingerprint & | id, |
cache_usize_type | size | ||
) | [inline, 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). |
Implements Sirikata::Transfer::CachePolicy.
References mLeastUsed, and Sirikata::Transfer::CachePolicy::updateSpace().
virtual void Sirikata::Transfer::LRUPolicy::destroy | ( | const Fingerprint & | id, |
Data * | data, | ||
cache_usize_type | size | ||
) | [inline, 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. |
Implements Sirikata::Transfer::CachePolicy.
References Sirikata::Logging::detailed, Sirikata::Transfer::CachePolicy::mFreeSpace, Sirikata::Transfer::LRUPolicy::LRUData::mIter, mLeastUsed, SILOG, and Sirikata::Transfer::CachePolicy::updateSpace().
virtual bool Sirikata::Transfer::LRUPolicy::nextItem | ( | cache_usize_type | requiredSpace, |
Fingerprint & | myprint | ||
) | [inline, virtual] |
Implements Sirikata::Transfer::CachePolicy.
References Sirikata::Transfer::CachePolicy::mFreeSpace, and mLeastUsed.
virtual void Sirikata::Transfer::LRUPolicy::use | ( | const Fingerprint & | id, |
Data * | data, | ||
cache_usize_type | size | ||
) | [inline, 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. |
Implements Sirikata::Transfer::CachePolicy.
References Sirikata::Transfer::LRUPolicy::LRUData::mIter, and mLeastUsed.
Referenced by useAndUpdate().
virtual void Sirikata::Transfer::LRUPolicy::useAndUpdate | ( | const Fingerprint & | id, |
Data * | data, | ||
cache_usize_type | oldsize, | ||
cache_usize_type | newsize | ||
) | [inline, 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. |
Implements Sirikata::Transfer::CachePolicy.
References Sirikata::Transfer::CachePolicy::updateSpace(), and use().
Referenced by create(), destroy(), nextItem(), and use().