xorp

cref_counter_pool Class Reference

class for maintaining the storage of counters used by cref_ptr. More...

#include <ref_ptr.hh>

List of all members.

Classes

struct  pool_item

Public Member Functions

int32_t new_counter (void *data)
 Create a new counter.
int32_t incr_counter (int32_t index)
 Increment the count associated with counter by 1.
int32_t decr_counter (int32_t index)
 Decrement the count associated with counter by 1.
int32_t count (int32_t index)
 Get the count associated with counter.
void * data (int32_t index)
void recycle (int32_t index)
 Recycle counter.
void dump ()
 Dumps counter info to stdout.
void check ()
 Sanity check internal data structure.

Static Public Member Functions

static cref_counter_poolinstance ()

Private Member Functions

void grow ()
 Expand counter storage.

Private Attributes

vector< pool_item_counters
int32_t _free_index

Static Private Attributes

static const int32_t LAST_FREE = -1
static cref_counter_pool _the_instance

Detailed Description

class for maintaining the storage of counters used by cref_ptr.

The cref_counter_pool is a singleton class that maintains the counters for all cref_ptr objects. The counters are maintained in a vector. This class is used by cref_ptr and not intended any other purpose.


Member Function Documentation

void cref_counter_pool::check ( )

Sanity check internal data structure.

Debugging function.

int32_t cref_counter_pool::count ( int32_t  index)

Get the count associated with counter.

Parameters:
indexof the counter to query.
Returns:
the counter value.
int32_t cref_counter_pool::decr_counter ( int32_t  index)

Decrement the count associated with counter by 1.

Parameters:
indexthe counter to decrement.
void cref_counter_pool::dump ( )

Dumps counter info to stdout.

Debugging function.

int32_t cref_counter_pool::incr_counter ( int32_t  index)

Increment the count associated with counter by 1.

Parameters:
indexthe counter to increment.
cref_counter_pool & cref_counter_pool::instance ( ) [static]
Returns:
singleton cref_counter_pool.
int32_t cref_counter_pool::new_counter ( void *  data)

Create a new counter.

Returns:
index associated with counter.
void cref_counter_pool::recycle ( int32_t  index)

Recycle counter.

Places counter on free-list.

Parameters:
indexof the counter to recycle.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations