cds  1.3.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
cds::gc::hrc::ContainerNode Class Referenceabstract

Base class for all HRC-based container's node. More...

#include <cds/gc/hrc/hrc.h>

Public Member Functions

unsigned_ref_counter::ref_counter_type getRefCount () const
 Returns count of reference for the node.
 
void incRefCount ()
 Increments the reference counter of the node.
 
bool decRefCount ()
 Decrements the reference counter of the node. Returns true if ref counter is 0.
 
bool isDeleted () const
 Returns the mark that the node is deleted or not.
 

Protected Member Functions

virtual void cleanUp (ThreadGC *pGC)=0
 
virtual void terminate (ThreadGC *pGC, bool bConcurrent)=0
 

Protected Attributes

unsigned_ref_counter m_RC
 reference counter
 
std::atomic< bool > m_bTrace
 true - node is tracing by Scan
 
std::atomic< bool > m_bDeleted
 @ true - node is deleted
 

Friends

class GarbageCollector
 
class ThreadGC
 
class gc::HRC
 

Detailed Description

Base class for all HRC-based container's node.

This interface is placed to the separate class since in the presence of a garbage collector the lifetime of the node is greater than lifetime of its container. Reclaimed node may be physically deleted later than its container. So, the ContainerNode must be smarter than the usual.

Member Function Documentation

virtual void cds::gc::hrc::ContainerNode::cleanUp ( ThreadGC pGC)
protectedpure virtual

[Gidenstam 2006]: "The procedure CleanUpNode will make sure that all claimed references from the links of the given node will only point to active nodes, thus removing redundant passages through an arbitrary number of deleted nodes"

The pseudocode of this method must be like following:

void cleanUp( ThreadGC * pGC )
for all x where link[x] of node is reference-counted do
retry:
node1 := link[x] ;
if node1 != NULL and node1.m_bDeleted then
node2 := node1->link[x] ;
pGC->CASRef( this->link[x], node1, node2 );
pGC->releaseRef( node2 );
pGC->releaseRef( node1 );
goto retry;
pGC->releaseRef(node1);

Be aware to use hazard pointers inside implementation of this method. cleanUp is called from the container's method when deleting the nodes. However, some hazard pointers may be occupied by container's method. You should allocate new hazard pointers inside cleanUp method, for example:

gc::hrc::AutoHPArray<2> hpArr( *pGC ) ;
virtual void cds::gc::hrc::ContainerNode::terminate ( ThreadGC pGC,
bool  bConcurrent 
)
protectedpure virtual

[Gidenstam 2006]: "The procedure TerminateNode will make sure that none of the links in the given node will have any claim on any other node. TerminateNode is called on a deleted node when there are no claims from any other node or thread to the node"

The pseudocode of this method must be like following:

void terminate( ThreadGC * pGC, bool bConcurrent)
if !bConcurrent
for all this->link where link is reference-counted do
link := NULL ;
else
for all this->link where link is reference-counted do
repeat node1 := link ;
until pGC->CASRef(link,node1,NULL);

The documentation for this class was generated from the following file:

cds 1.3.0 Developed by Maxim Khiszinsky aka khizmax 2007 - 2012
Autogenerated Sat Dec 29 2012 19:12:34 by Doxygen 1.8.3