SAMRAI::tbox::ReferenceCounter Class Reference

#include <source/toolbox/memory/ReferenceCounter.h>

List of all members.

Public Member Functions

 ReferenceCounter ()
 ReferenceCounter (Arena *newArena, ReferenceCounter *arenaCounter)
 ~ReferenceCounter ()
ArenagetArena ()
bool deleteReference ()
void addReference ()
void * operator new (size_t bytes)
void operator delete (void *what)

Static Public Member Functions

static void freeCachedCopies ()


Detailed Description

Class ReferenceCounter manages the shared reference counter and arena resources used by Pointer and Array. It uses a local free pool of objects to speed memory allocation and deallocation. The locally cached free pool can be freed by calling freeCachedCopies().

{Do not subclass!} Changing the size of a ReferenceCounter object will cause my simple memory allocation mechanism to break in horrible and disgusting ways.

See also:
tbox::Array

tbox::Pointer


Constructor & Destructor Documentation

SAMRAI::tbox::ReferenceCounter::ReferenceCounter (  )  [inline]

Create a ReferenceCounter with an unmanaged memory arena. The number of references is set to one.

SAMRAI::tbox::ReferenceCounter::ReferenceCounter ( Arena newArena,
ReferenceCounter arenaCounter 
)

Create a ReferenceCounter with a managed memory arena. Argument newArena is the managed memory arena and arenaCounter is the reference counter for that arena. The number of references is set to one.

SAMRAI::tbox::ReferenceCounter::~ReferenceCounter (  ) 

Destructor for ReferenceCounter. The destructor releases the managed memory arena if its count has gone to zero.


Member Function Documentation

Arena * SAMRAI::tbox::ReferenceCounter::getArena (  )  [inline]

Get the managed memory arena (or NULL if none exists).

bool SAMRAI::tbox::ReferenceCounter::deleteReference (  )  [inline]

Decrement the number of references. True is returned if the reference count has gone to zero; false otherwise.

void SAMRAI::tbox::ReferenceCounter::addReference (  )  [inline]

Increment the number of references.

void SAMRAI::tbox::ReferenceCounter::freeCachedCopies (  )  [static]

Release the memory for all currently cached ReferenceCounter copies. This function may be called at any time. In general, it should not be necessary to call freeCachedCopies(), since it is called via the ShutdownRegistry mechanism.

void * SAMRAI::tbox::ReferenceCounter::operator new ( size_t  bytes  ) 

Class-specific operator new. Data is allocated off of an internal free list to speed memory allocation.

void SAMRAI::tbox::ReferenceCounter::operator delete ( void *  what  ) 

Class-specific operator delete. Freed data is returned to an internal free list for re-use by operator new.


The documentation for this class was generated from the following files:
Generated on Thu Jun 18 11:29:06 2009 for SAMRAI by  doxygen 1.5.1