Share Library (C++)
File detail
Source code
/**
* @file DefaultRefCounter.cpp
* @brief Reference counter for shared segment
* @author Kamil Dudka, xdudka00@gmail.com
* @date 2007-05-15
* @ingroup backend
*/
#include "DefaultRefCounter.h"
using namespace Share;
DefaultRefCounter::DefaultRefCounter() throw (ShareException):
refCount_(0),
unlinked_(false)
{
}
DefaultRefCounter::~DefaultRefCounter ()
{
}
void DefaultRefCounter::notifyAttach ()
{
++refCount_;
}
void DefaultRefCounter::notifyDetach ()
{
--refCount_;
}
int DefaultRefCounter::refCount() const
{
return refCount_;
}
void DefaultRefCounter::unlink ()
{
unlinked_= true;
}
bool DefaultRefCounter::isUnlinked () const
{
return unlinked_;
}
bool DefaultRefCounter::shouldBeDestroyed () const
{
return unlinked_ && (refCount_ <=0);
}