iopc::ArcCache< MapType > Class Template Reference
[iopclib-cache]

#include <arcCache.h>

Inheritance diagram for iopc::ArcCache< MapType >:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual long getActiveCost ()
virtual long getLockedCost ()
virtual long getWorstValue (const TimeStamp &current)
virtual long removeWorst ()
virtual bool maintainerStep (long &costChange)
virtual long getSleepTime (const TimeStamp &current, long minValue)
virtual Cacheclone ()
 Creates a copy of the current cache.

Protected Member Functions

virtual void clear (const StrategySelector &strSel)
virtual CacheLockmakePersistent (const StrategySelector &strSel, const PersIdentification &persId, DatabaseObject &objectPtr)
virtual CacheLockgetCacheLock (const StrategySelector &strSel, const PersIdentification &persId, bool rdonly=false)
virtual void dbDelete (const StrategySelector &strSel, const PersIdentification &persId)
virtual void cacheDelete (const StrategySelector &strSel, const PersIdentification &persId)
virtual void updateDirty (const StrategySelector &strSel)
virtual void removeAll (const StrategySelector &strSel)
ArcCacheItemaddLock (ArcCacheItem &item, bool rdonly)
void rmLock (ArcCacheItem &item)
virtual bool removeDoomed ()
virtual bool removeZombie ()
virtual bool asyncUpdate (long &costChange)

Protected Attributes

MapType cont
RWLock contLock
Mutex listLock
CondVar busyCond
long rActiveCnt
long rLockedCnt
long fActiveCnt
long fLockedCnt
long rHistCnt
long fHistCnt
ArcCacheItem rCleanList
ArcCacheItem rHistList
ArcCacheItem rDirtyList
ArcCacheItem fCleanList
ArcCacheItem fHistList
ArcCacheItem fDirtyList
ArcCacheItem doomedList
ArcCacheItem zombieList
long activeCost
long lockedCost
double target


Detailed Description

template<typename MapType>
class iopc::ArcCache< MapType >

Multithreaded cache using ARC replacement policy. Objects are represented by ArcCacheItem. Items are stored an container conforming to STL "pair associative container" concept. Its type is specified by template parameter.

Member Function Documentation

template<typename MapType>
void iopc::ArcCache< MapType >::clear ( const StrategySelector strSel  )  [inline, protected, virtual]

Synchronizes states of the cache and database. Removes all objects. Makes it possible to harmlessly break association of the cache and its connection. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.

Implements iopc::ExtendedCache.

template<typename MapType>
CacheLock & iopc::ArcCache< MapType >::makePersistent ( const StrategySelector strSel,
const PersIdentification persId,
DatabaseObject objectPtr 
) [inline, protected, virtual]

Saves an object into database. Locks it in cache. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.
persId ID of the object.
obj Object to be made persistent.
Returns:
An instance representing locked object and making it possible to read and modify the object.

Implements iopc::ExtendedCache.

template<typename MapType>
CacheLock & iopc::ArcCache< MapType >::getCacheLock ( const StrategySelector strSel,
const PersIdentification persId,
bool  rdonly = false 
) [inline, protected, virtual]

Assures an object is in cache, locks it and returns an instance making it possible to access the object. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.
persId ID of the object.
rdonly Indicates the type of required access to the object (read-only/write).
Returns:
An instance making it possible to access the object.

Implements iopc::ExtendedCache.

template<typename MapType>
void iopc::ArcCache< MapType >::dbDelete ( const StrategySelector strSel,
const PersIdentification persId 
) [inline, protected, virtual]

Deletes an object. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.
persId ID of the object.

Implements iopc::ExtendedCache.

template<typename MapType>
void iopc::ArcCache< MapType >::cacheDelete ( const StrategySelector strSel,
const PersIdentification persId 
) [inline, protected, virtual]

Represents a hint for the cache to remove local copy of an object. Can be ignored. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.
persId ID of the object.

Implements iopc::ExtendedCache.

template<typename MapType>
void iopc::ArcCache< MapType >::updateDirty ( const StrategySelector strSel  )  [inline, protected, virtual]

Synchronize the state of cache and DB by updating the DB. Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.

Implements iopc::ExtendedCache.

template<typename MapType>
void iopc::ArcCache< MapType >::removeAll ( const StrategySelector strSel  )  [inline, protected, virtual]

Synchronize the state of cache and DB by discarding all kept object (without modifications to DB).http://www-ucjf.troja.mff.cuni.cz/scheirich/comics/mff_life_09.jpg Uses strategy selector passed by caller.

Parameters:
strSel The strategy selector.

Implements iopc::ExtendedCache.

template<typename MapType>
ArcCacheItem & iopc::ArcCache< MapType >::addLock ( ArcCacheItem item,
bool  rdonly 
) [inline, protected, virtual]

Adds a lock to an item containing an object

Parameters:
item The item the lock should be added to.
rdonly Type of the lock.
Returns:
An item representing new lock (it's the same as the passed one)

Implements iopc::ArcCacheBase.

template<typename MapType>
void iopc::ArcCache< MapType >::rmLock ( ArcCacheItem item  )  [inline, protected, virtual]

Removes one lock of an item representing an object

Parameters:
item The item the lock should be removed from.

Implements iopc::ArcCacheBase.

template<typename MapType>
long iopc::ArcCache< MapType >::getActiveCost (  )  [inline, virtual]

Returns total cost of objects which can be removed from cache (i.e. are not locked).

Reimplemented from iopc::ExtendedCache.

template<typename MapType>
long iopc::ArcCache< MapType >::getLockedCost (  )  [inline, virtual]

Returns total cost of objects which can't be removed from cache (i.e. are locked).

Reimplemented from iopc::ExtendedCache.

template<typename MapType>
long iopc::ArcCache< MapType >::getWorstValue ( const TimeStamp current  )  [inline, virtual]

Returns value of the object having minimal value.

Reimplemented from iopc::ExtendedCache.

template<typename MapType>
long iopc::ArcCache< MapType >::removeWorst (  )  [inline, virtual]

Removes the object with minimal value.

Reimplemented from iopc::ExtendedCache.

template<typename MapType>
bool iopc::ArcCache< MapType >::maintainerStep ( long &  costChange  )  [inline, virtual]

Function executing one elementar maintenance step

Returns:
false when there's no work for maintainer, true otherwise.

Reimplemented from iopc::ExtendedCache.

template<typename MapType>
long iopc::ArcCache< MapType >::getSleepTime ( const TimeStamp current,
long  minValue 
) [inline, virtual]

Gets the time it's possible to sleep for the external maintainer (unless it's woken up).

Returns:
Maximal number of milliseconds the cache doesn't need to be externally maintained for.

Reimplemented from iopc::ExtendedCache.

template<typename MapType>
bool iopc::ArcCache< MapType >::removeDoomed (  )  [inline, protected, virtual]

Remove one object scheduled for deletion.

Returns:
false there are no objects scheduled for deletion, true otherwise.

template<typename MapType>
bool iopc::ArcCache< MapType >::removeZombie (  )  [inline, protected, virtual]

Removes one zombie. Zombies are created when an item can't removed from container because of the danger of deadlock.

Returns:
false when there are no zombies present, true otherwise.

template<typename MapType>
bool iopc::ArcCache< MapType >::asyncUpdate ( long &  costChange  )  [inline, protected, virtual]

Updates one modified unlocked object.

Parameters:
costChange Output parameter, the change of total cost caused by method call.
Returns:
false when there are no modified unlocked objects present, true otherwise.


Member Data Documentation

template<typename MapType>
MapType iopc::ArcCache< MapType >::cont [protected]

Container holding items of all types - locked/unlocked, representing scheduled actions, modified, history, ...

template<typename MapType>
RWLock iopc::ArcCache< MapType >::contLock [protected]

Locks items in container.

template<typename MapType>
Mutex iopc::ArcCache< MapType >::listLock [protected]

Common lock needed when modifying lists.

template<typename MapType>
CondVar iopc::ArcCache< MapType >::busyCond [protected]

Conditional for signaling state change from ST_BUSY to something else.

template<typename MapType>
long iopc::ArcCache< MapType >::rActiveCnt [protected]

Number of unlocked objects (recent).

template<typename MapType>
long iopc::ArcCache< MapType >::rLockedCnt [protected]

Number of locked objects (recent).

template<typename MapType>
long iopc::ArcCache< MapType >::fActiveCnt [protected]

Number of unlocked objects (frequent).

template<typename MapType>
long iopc::ArcCache< MapType >::fLockedCnt [protected]

Number of locked objects (frequent).

template<typename MapType>
long iopc::ArcCache< MapType >::rHistCnt [protected]

Number of items representing history (recent).

template<typename MapType>
long iopc::ArcCache< MapType >::fHistCnt [protected]

Number of items representing history (frequent).

template<typename MapType>
ArcCacheItem iopc::ArcCache< MapType >::rCleanList [protected]

List of objects which doesn't require async update (recent).

template<typename MapType>
ArcCacheItem iopc::ArcCache< MapType >::rHistList [protected]

List of history records (recent).

template<typename MapType>
ArcCacheItem iopc::ArcCache< MapType >::rDirtyList [protected]

List of objects requiring async update (recent).

template<typename MapType>
ArcCacheItem iopc::ArcCache< MapType >::fCleanList [protected]

List of objects which doesn't require async update (frequent).

template<typename MapType>
ArcCacheItem iopc::ArcCache< MapType >::fHistList [protected]

List of history records (frequent).

template<typename MapType>
ArcCacheItem iopc::ArcCache< MapType >::fDirtyList [protected]

List of objects requiring async update (frequent).

template<typename MapType>
ArcCacheItem iopc::ArcCache< MapType >::doomedList [protected]

List of items scheduled for deletion.

template<typename MapType>
ArcCacheItem iopc::ArcCache< MapType >::zombieList [protected]

List of zombies.

template<typename MapType>
long iopc::ArcCache< MapType >::activeCost [protected]

Total cost of unlocked items (recent and frequent).

template<typename MapType>
long iopc::ArcCache< MapType >::lockedCost [protected]

Total cost of locked items (recent and frequent).

template<typename MapType>
double iopc::ArcCache< MapType >::target [protected]

Target for ratio activeCost/lockedCost.


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

Generated on Tue Apr 14 16:46:40 2009 for IOPC 2 by  doxygen 1.5.6