Share Library (C++)
File detail
Source code
#ifndef DEFAULT_REFCOUNTER_H
#define DEFAULT_REFCOUNTER_H
/**
* @file DefaultRefCounter.h
* @brief Reference counter for shared segment
* @author Kamil Dudka, xdudka00@gmail.com
* @date 2007-05-15
* @ingroup backend
*/
#include "sharelib.h"
namespace Share {
/**
* @brief Reference counter for shared segment
* @note This class can be replaced with more efficient class with equivalet interface by changing Share::TSegmentRefCounter
* @ingroup backend
*/
class DefaultRefCounter/*: public AbstractRefCounter*/ {
public:
/**
* @throw ShareException Library-specific exception derived from std::bad_alloc
*/
DefaultRefCounter() throw (ShareException);
~DefaultRefCounter();
/**
* Client attach notification. This increase reference count.
*/
void notifyAttach();
/**
* Client detach notification. This decrease reference count.
*/
void notifyDetach();
/**
* @return Return current count of references.
*/
int refCount() const;
/**
* Mark segment to be destroyed.
*/
void unlink();
/**
* @return Return true if segment is marked to be destroyed.
*/
bool isUnlinked() const;
/**
* @return Return true if segment should be destroyed. This means, segment
* is unlinked and references count is zero.
*/
bool shouldBeDestroyed() const;
private:
int refCount_;
bool unlinked_;
};
}
#endif // DEFAULT_REFCOUNTER_H