Sirikata
Classes | Public Member Functions | Private Types | Private Attributes
Sirikata::Transfer::LRUPolicy Class Reference

Simple LRU policy--does not do any ordering by size. More...

#include <LRUPolicy.hpp>

Inheritance diagram for Sirikata::Transfer::LRUPolicy:
Collaboration diagram for Sirikata::Transfer::LRUPolicy:

List of all members.

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 Datacreate (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< LRUElementLRUList

Private Attributes

LRUList mLeastUsed

Detailed Description

Simple LRU policy--does not do any ordering by size.


Member Typedef Documentation

typedef std::list<LRUElement> Sirikata::Transfer::LRUPolicy::LRUList [private]

Constructor & Destructor Documentation

Sirikata::Transfer::LRUPolicy::LRUPolicy ( cache_usize_type  allocatedSpace,
float  maxSizePct = 0.5 
) [inline]

Member Function Documentation

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().

Parameters:
idThe FileId corresponding to the data.
sizeThe amount of space allocated (should be the same as was earlier passed to allocateSpace).
Returns:
The corresponding opaque data.

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)

Parameters:
idThe FileId corresponding to the data.
dataThe opaque data corresponding to this policy.
sizeThe 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]
virtual void Sirikata::Transfer::LRUPolicy::use ( const Fingerprint id,
Data data,
cache_usize_type  size 
) [inline, virtual]

Marks the entry as used.

Parameters:
idThe FileId corresponding to the data.
dataThe opaque data corresponding to this policy.
sizeThe 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.

Parameters:
idThe FileId corresponding to the data.
dataThe opaque data corresponding to this policy.
oldsizeThe previous size of the data.
newsizeThe new size of the data.

Implements Sirikata::Transfer::CachePolicy.

References Sirikata::Transfer::CachePolicy::updateSpace(), and use().


Member Data Documentation

Referenced by create(), destroy(), nextItem(), and use().


The documentation for this class was generated from the following file: