eq::net::InstanceCache Class Reference

A thread-safe cache for object instance data. More...

#include <instanceCache.h>

Collaboration diagram for eq::net::InstanceCache:
Collaboration graph
[legend]

List of all members.

Classes

struct  Data
 One cache entry. More...
struct  Item

Public Member Functions

 InstanceCache (const long maxSize=EQ_100MB)
 Construct a new instance cache.
 ~InstanceCache ()
 Destruct this instance cache.
bool add (const ObjectVersion &rev, const uint32_t instanceID, Command &command, const uint32_t usage=0)
 Add a new command to the instance cache.
const Dataoperator[] (const uint32_t id)
 Direct access to the cached instance data for the given object id.
bool release (const uint32_t id, const uint32_t count=1)
 Release the retrieved instance data of the given object.
bool erase (const uint32_t id)
 Erase all the data for the given object.
long getSize () const
void expire (const int64_t age)
 Remove all items which are older than the given time.

Detailed Description

A thread-safe cache for object instance data.

For internal use only.

Definition at line 41 of file instanceCache.h.


Constructor & Destructor Documentation

eq::net::InstanceCache::InstanceCache ( const long  maxSize = EQ_100MB  ) 

Construct a new instance cache.

Definition at line 46 of file instanceCache.cpp.

eq::net::InstanceCache::~InstanceCache (  ) 

Destruct this instance cache.

Definition at line 51 of file instanceCache.cpp.


Member Function Documentation

bool eq::net::InstanceCache::add ( const ObjectVersion rev,
const uint32_t  instanceID,
Command command,
const uint32_t  usage = 0 
)

Add a new command to the instance cache.

Parameters:
rev the object identifier and version.
instanceID the master instance ID.
command The command to add.
usage pre-set usage count.
Returns:
true if the command was entered, false if not.

Definition at line 85 of file instanceCache.cpp.

References EQ_MAX, and eq::base::Clock::getTime64().

Here is the call graph for this function:

const InstanceCache::Data & eq::net::InstanceCache::operator[] ( const uint32_t  id  ) 

Direct access to the cached instance data for the given object id.

The instance data for the given object has to be released by the caller, unless 0 has been returned. Not all returned data stream might be ready.

Parameters:
id the identifier of the object to look up.
Returns:
the list of cached instance datas, or Data::NONE if no data is cached for this object.

Definition at line 171 of file instanceCache.cpp.

References EQINFO, and eq::net::InstanceCache::Data::NONE.

bool eq::net::InstanceCache::release ( const uint32_t  id,
const uint32_t  count = 1 
)

Release the retrieved instance data of the given object.

Parameters:
id the identifier of the object to release.
count the number of access operations to release
Returns:
true if the element was unpinned, false if it is not in the instance cache.

Definition at line 196 of file instanceCache.cpp.

bool eq::net::InstanceCache::erase ( const uint32_t  id  ) 

Erase all the data for the given object.

The data does not have to be accessed, i.e., release has been called for each previous access.

Returns:
true if the element was erased, false otherwise.

Definition at line 212 of file instanceCache.cpp.

long eq::net::InstanceCache::getSize (  )  const [inline]
Returns:
the number of bytes used by the instance cache.

Definition at line 108 of file instanceCache.h.

void eq::net::InstanceCache::expire ( const int64_t  age  ) 

Remove all items which are older than the given time.

Definition at line 228 of file instanceCache.cpp.

References EQWARN, and eq::base::Clock::getTime64().

Referenced by eq::net::Session::expireInstanceData().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Sat Feb 6 13:09:39 2010 for Equalizer 0.9.1 by  doxygen 1.6.1