Sirikata
Classes | Public Member Functions | Protected Member Functions | Protected Attributes
Sirikata::Transfer::CachePolicy Class Reference

Critical to the functioning of CacheLayer--makes decisions which pieces of data to keep and which to throw out. More...

#include <CachePolicy.hpp>

Inheritance diagram for Sirikata::Transfer::CachePolicy:
Collaboration diagram for Sirikata::Transfer::CachePolicy:

List of all members.

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

Detailed Description

Critical to the functioning of CacheLayer--makes decisions which pieces of data to keep and which to throw out.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Parameters:
requiredSpacethe amount of space this single entry needs
Returns:
whether the space could be allocated

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

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.

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)

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

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.

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.

Implemented in Sirikata::Transfer::LRUPolicy.

Referenced by Sirikata::Transfer::CacheMap::write_iterator::update().


Member Data Documentation

Referenced by cachable().

Referenced by cachable().


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