xorp

ref_counter_pool Class Reference

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

#include <ref_ptr.hh>

List of all members.

Public Member Functions

int32_t new_counter ()
 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 recycle (int32_t index)
 Recycle counter.
void dump ()
 Dumps counter info to stdout.
void check ()
 Sanity check internal data structure.
bool on_free_list (int32_t index)
 Check index is on free list.
int32_t balance () const
 Return number of valid ref pointer entries in pool.

Static Public Member Functions

static ref_counter_poolinstance ()

Private Member Functions

void grow ()
 Expand counter storage.

Private Attributes

vector< int32_t > _counters
int32_t _free_index
int32_t _balance

Static Private Attributes

static const int32_t LAST_FREE = -1
static ref_counter_pool _the_instance

Detailed Description

class for maintaining the storage of counters used by ref_ptr.

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


Member Function Documentation

void ref_counter_pool::check ( )

Sanity check internal data structure.

Debugging function.

int32_t ref_counter_pool::count ( int32_t  index)

Get the count associated with counter.

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

Decrement the count associated with counter by 1.

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

Dumps counter info to stdout.

Debugging function.

int32_t ref_counter_pool::incr_counter ( int32_t  index)

Increment the count associated with counter by 1.

Parameters:
indexthe counter to increment.
ref_counter_pool & ref_counter_pool::instance ( ) [static]
Returns:
singleton ref_counter_pool.
int32_t ref_counter_pool::new_counter ( )

Create a new counter.

Returns:
index associated with counter.
void ref_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