Sirikata
Public Member Functions | Private Attributes
Sirikata::Transfer::CacheMap::read_iterator Class Reference

A read-only iterator. More...

#include <CacheMap.hpp>

Collaboration diagram for Sirikata::Transfer::CacheMap::read_iterator:

List of all members.

Public Member Functions

 read_iterator (CacheMap &m)
 Construct from a CacheMap (contains a scoped read lock)
 operator bool () const
bool iterate ()
bool find (const Fingerprint &id)
 Moves this iterator to id.
CacheData operator* () const
const FingerprintgetId () const
cache_usize_type getSize () const
PolicyData getPolicyInfo ()
void use ()
 Sets the use bit in the corresponding cache policy.

Private Attributes

CacheMapmCachemap
boost::shared_lock
< boost::shared_mutex > 
mLock
MapClassmMap
MapClass::iterator mIter

Detailed Description

A read-only iterator.

Not const because the LRU use-count is allowed to be updated, even though the CacheLayer cannot be changed. A read_iterator locks the map using a boost::shared_lock. This means that any number of read_iterator objects are allowed access at the same time, except when a write_iterator is in use.


Constructor & Destructor Documentation

Sirikata::Transfer::CacheMap::read_iterator::read_iterator ( CacheMap m) [inline]

Construct from a CacheMap (contains a scoped read lock)


Member Function Documentation

bool Sirikata::Transfer::CacheMap::read_iterator::find ( const Fingerprint id) [inline]

Moves this iterator to id.

Parameters:
idwhat to search for
Returns:
if the find was successful.

References mIter, and mMap.

Referenced by Sirikata::Transfer::MemoryCacheLayer::getData(), Sirikata::Transfer::DiskCacheLayer::getData(), and Sirikata::Transfer::DiskCacheLayer::workerThread().

const Fingerprint& Sirikata::Transfer::CacheMap::read_iterator::getId ( ) const [inline]
Returns:
the current ID (does not check validity)

Referenced by use().

PolicyData Sirikata::Transfer::CacheMap::read_iterator::getPolicyInfo ( ) [inline]
Returns:
the CachePolicy opaque data (does not check validity)

Referenced by use().

cache_usize_type Sirikata::Transfer::CacheMap::read_iterator::getSize ( ) const [inline]
Returns:
the stored space usage of this item.

Referenced by use().

bool Sirikata::Transfer::CacheMap::read_iterator::iterate ( ) [inline]

References mIter, and mMap.

Sirikata::Transfer::CacheMap::read_iterator::operator bool ( ) const [inline]
Returns:
if this iterator can be dereferenced.

References mIter, and mMap.

CacheData Sirikata::Transfer::CacheMap::read_iterator::operator* ( ) const [inline]
Returns:
the current CacheInfo (does not check validity)
void Sirikata::Transfer::CacheMap::read_iterator::use ( ) [inline]

Member Data Documentation

Referenced by use().

Referenced by find(), iterate(), and operator bool().

boost::shared_lock<boost::shared_mutex> Sirikata::Transfer::CacheMap::read_iterator::mLock [private]

Referenced by find(), iterate(), and operator bool().


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