All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Member Functions | Friends
QGpCoreTools::CacheItem Class Reference

Brief description of class still missing. More...

#include <CacheItem.h>

Inheritance diagram for QGpCoreTools::CacheItem:
GeopsyCore::SignalTemplate< sampleType >

List of all members.

Public Member Functions

void addProcess (CacheProcess *p) const
 CacheItem ()
 CacheItem (const CacheItem &o)
quint64 nextPredictedTime () const
void removeProcess (CacheProcess *p) const
virtual ~CacheItem ()

Protected Member Functions

virtual bool allocate () const =0
virtual int dataSize () const =0
virtual QString debugName () const
virtual void free () const =0
virtual bool isAllocated () const =0
bool isSaved () const
virtual void load (QDir &d) const =0
void lockData () const
virtual void save (QDir &d) const =0
QString swapFileName () const
void unlockData () const

Friends

class AllocatedCacheItem
class Cache

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

CacheItem::CacheItem ( ) [inline]

Description of constructor still missing

References QGpCoreTools::ApplicationClock::elapsed(), and TRACE.

                               : _dataLock(QMutex::Recursive)
  {
    TRACE;
    _lastAccess=ApplicationClock::elapsed();
    _saved=false;
    _lockCount=0;
  }
CacheItem::CacheItem ( const CacheItem o) [inline]

Description of copy constructor still missing

References QGpCoreTools::ApplicationClock::elapsed(), and TRACE.

                                                 : _dataLock(QMutex::Recursive)
  {
    TRACE;
    _lastAccess=ApplicationClock::elapsed();
    _saved=false;
    _lockCount=0;
  }
CacheItem::~CacheItem ( ) [virtual]

Assert if still locked or saved

{
  ASSERT(_lockCount==0);
  ASSERT(!_saved);
  _processLock.lock();
  for(QSet<CacheProcess *>::const_iterator it=_processes.begin(); it!=_processes.end(); it++) {
    (*it)->remove(this);
  }
  _processLock.unlock();
}

Member Function Documentation

void CacheItem::addProcess ( CacheProcess p) const [inline]

Referenced by QGpCoreTools::CacheProcess::add(), and QGpCoreTools::CacheProcess::operator<<().

  {
    _processLock.lock();
    _processes.insert(p);
    _processLock.unlock();
  }
bool CacheItem::allocate ( ) const [protected, pure virtual]

Implement this function to allocate the data. Return true if successful.

Referenced by QGpCoreTools::Cache::makeAvailable().

int CacheItem::dataSize ( ) const [protected, pure virtual]

Implement this function to return the size of the data to allocate in bytes.

Implemented in GeopsyCore::SignalTemplate< sampleType >.

Referenced by QGpCoreTools::Cache::enlarge(), QGpCoreTools::Cache::free(), QGpCoreTools::AllocatedCacheItem::humanInfo(), and QGpCoreTools::Cache::makeAvailable().

virtual QString QGpCoreTools::CacheItem::debugName ( ) const [inline, protected, virtual]
{return swapFileName();}
void CacheItem::free ( ) const [protected, pure virtual]

Implement this function to free the data. Never call this function directly, use Cache::free() instead.

Referenced by QGpCoreTools::Cache::free().

bool CacheItem::isAllocated ( ) const [protected, pure virtual]

Implement this function to return true is data is allocated.

Implemented in GeopsyCore::SignalTemplate< sampleType >.

Referenced by QGpCoreTools::Cache::free().

bool QGpCoreTools::CacheItem::isSaved ( ) const [inline, protected]
{return _saved;}
void CacheItem::load ( QDir &  d) const [protected, pure virtual]

Implement this function to load the data from disk upon request.

See also:
load()

Referenced by QGpCoreTools::Cache::makeAvailable().

void CacheItem::lockData ( ) const [inline, protected]

lock() and unlock() are necessary to control allocation/deallocation of item data in cache. When an item is locked the cache manager cannot deallocate the item data. unlockData() leaves the item data in the cache and the data will be deallocated if requested by new allocations.

See also:
unlockData()
  {
    _dataLock.lock();
    _lockCount++;
  }
quint64 CacheItem::nextPredictedTime ( ) const

Returns the predicted time of the next usage of this item.

References MAXIMUM_APPLICATION_LIFETIME.

Referenced by QGpCoreTools::AllocatedCacheItem::bestToFree().

{
  quint64 tMin=MAXIMUM_APPLICATION_LIFETIME;
  quint64 t;
  for(QSet<CacheProcess *>::iterator it=_processes.begin(); it!=_processes.end(); it++) {
    t=(*it)->predictedTime(this);
    if(t<tMin) {
      tMin=t;
    }
  }
  return tMin;
}
void CacheItem::removeProcess ( CacheProcess p) const [inline]
  {
    _processLock.lock();
    _processes.remove(p);
    _processLock.unlock();
  }
void CacheItem::save ( QDir &  d) const [protected, pure virtual]

Implement this function to save the data to disk when memory usage requires it.

Referenced by QGpCoreTools::Cache::free().

QString QGpCoreTools::CacheItem::swapFileName ( ) const [inline, protected]

Referenced by QGpCoreTools::Cache::free(), and QGpCoreTools::Cache::makeAvailable().

{return QString("cache_data_%1").arg((ulong) this, 0, 16);}
void CacheItem::unlockData ( ) const [inline, protected]
See also:
lockData()

References QGpCoreTools::ApplicationClock::elapsed().

  {
    _lockCount--;
    _lastAccess=ApplicationClock::elapsed();
    _dataLock.unlock();
  }

Friends And Related Function Documentation

friend class AllocatedCacheItem [friend]
friend class Cache [friend]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines