ememory::Counter Class Reference

#include <Counter.hpp>

Public Types

enum  remove { remove::none, remove::data, remove::counter, remove::all }
 

Public Member Functions

 Counter (bool _fromWeak=false)
 
 ~Counter ()
 
int64_t incrementShared (bool _fromWeak=false)
 
ememory::Counter::remove decrementShared ()
 
int64_t incrementWeak ()
 
ememory::Counter::remove decrementWeak ()
 
int64_t getCountWeak () const
 
int64_t getCountShared () const
 
int64_t getCount () const
 

Detailed Description

Couter is an important part of the SharedPtr/WeakPtr implementation. This use a simple refcounting method dut thread-safe.

Member Enumeration Documentation

§ remove

Remove case of the counter. When decrese the shared our weak counter, it is the upper class that need to remove the counter of the data pointer.

Enumerator
none 

Noting to remove.

data 

Remove only the data.

counter 

Remove only the Counter (data already removed)

all 

Remove Data and Counter.

Constructor & Destructor Documentation

§ Counter()

ememory::Counter::Counter ( bool  _fromWeak = false)

Contructor.

Parameters
[in]_fromWeakCounter is created from a WeakPtr instead of a SharedPtr

§ ~Counter()

ememory::Counter::~Counter ( )

Destrunctor (Not virtual !!)

Member Function Documentation

§ decrementShared()

ememory::Counter::remove ememory::Counter::decrementShared ( )

Decrese of 1 the shared counter.

Returns
The action to do on the pointer or the counter

§ decrementWeak()

ememory::Counter::remove ememory::Counter::decrementWeak ( )

Decrese of 1 the weak counter.

Returns
The action to do on the pointer or the counter

§ getCount()

int64_t ememory::Counter::getCount ( ) const

Get the number of weak+shared counter.

Returns
Number of WeakPtr and SharedPtr connected.

§ getCountShared()

int64_t ememory::Counter::getCountShared ( ) const

Get the number of shared counter.

Returns
Number of SharedPtr connected.

§ getCountWeak()

int64_t ememory::Counter::getCountWeak ( ) const

Get the number of weak counter.

Returns
Number of WeakPtr connected.

§ incrementShared()

int64_t ememory::Counter::incrementShared ( bool  _fromWeak = false)

Increment the shared counter (one more shared user)

Parameters
[in]_fromWeakAt true if the increment came from a WeakPtr instead of a SharedPtr
Returns
Number of current SharedPtr that has been curently access at this data. Return 0 if the increment is not possible (object has no more SharedPtr)

§ incrementWeak()

int64_t ememory::Counter::incrementWeak ( )

Increment the weak counter (one more weak user)

Returns
Number of current WeakPtr that has been curently access at this data.

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