Counted Class Reference
[Kernel Module]

#include <counted.h>

Inheritance diagram for Counted:

BaseMessage Directory Object Message< Type > Message< ActionEvent > Message< EmptyMessage > Message< InputEvent > Message< PathRequest > Message< PathResponse > Message< StateEvent > Root

List of all members.

Detailed Description

Implements counted pointers.

Call AcquirePointer method to get counted pointer to this object. Deleting by delete operator is not allowed, use Release method instead. AcquirePointer can return NULL if object has been deleted from another thread in the same time.
Object is not deleted from memory until number of pointers is zero. This is usefull if you want to be sure that your object still exists.
This class is thread-safe execpt one case - the absotelly last deleted object. It must be deleted safetely from one thread and no other thread can acquire pointer simultaneously. This is provided by root node in KernelServer in our engine.

Usage example:

Counted *p = new Counted();           // create object (first conted pointer is set)

Counted *cp1 = p->AcquirePointer();   // get next counted pointer
Counted *cp2 = p->AcquirePointer();   // get another counted opinter

p->Release();                         // object is not deleted from memory, only number of counted pointers is decreased

cp1->Release();                       // object still exists
cp2->Release();                       // now the object is deleted from memory

Public Member Functions

 Counted ()
CountedAcquirePointer ()
virtual bool Release ()

Protected Member Functions

virtual ~Counted ()

Static Protected Member Functions

static void LockCounted ()
static void UnlockCounted ()

Private Attributes

uint_t pointers_count
 Number of pointers to this object.

Static Private Attributes

static uint_t instances_count = 0
 Number of all instances of Counted object.
static Mutexcounted_mutex = NULL
 Mutex for changing pointers count.

Constructor & Destructor Documentation

Counted::Counted (  )  [inline]

Counted::~Counted (  )  [inline, protected, virtual]

Member Function Documentation

Counted * Counted::AcquirePointer (  )  [inline]

bool Counted::Release (  )  [inline, virtual]

void Counted::LockCounted (  )  [inline, static, protected]

void Counted::UnlockCounted (  )  [inline, static, protected]

Member Data Documentation

uint_t Counted::pointers_count [private]

Number of pointers to this object.

uint_t Counted::instances_count = 0 [static, private]

Number of all instances of Counted object.

Mutex * Counted::counted_mutex = NULL [static, private]

Mutex for changing pointers count.

The documentation for this class was generated from the following files:
Generated on Sat Oct 20 14:47:31 2007 for Dark Oberon by  doxygen 1.5.3