/* === H E A D E R S ======================================================= */
-// include the next line in an attempt to increase stability
-#define ETL_LOCK_REFCOUNTS
-
#include <cassert>
-#ifdef ETL_LOCK_REFCOUNTS
-#include <synfig/mutex.h>
-#endif
/* === M A C R O S ========================================================= */
{
private:
mutable int refcount;
-#ifdef ETL_LOCK_REFCOUNTS
- mutable synfig::Mutex mutex;
-#endif
protected:
shared_object():refcount(0) { }
public:
void ref()const
- {
-#ifdef ETL_LOCK_REFCOUNTS
- synfig::Mutex::Lock lock(mutex);
-#endif
- assert(refcount>=0); refcount++;
- }
+ { assert(refcount>=0); refcount++; }
//! Returns \c false if object needs to be deleted
bool unref()const
{
-#ifdef ETL_LOCK_REFCOUNTS
- synfig::Mutex::Lock lock(mutex);
-#endif
assert(refcount>0);
refcount--;
if(refcount==0) {
#ifdef ETL_SELF_DELETING_SHARED_OBJECT
refcount=-666;
-#ifdef ETL_LOCK_REFCOUNTS
- mutex.unlock();
-#endif
delete this;
#endif
return false;
}
int count()const
- {
-#ifdef ETL_LOCK_REFCOUNTS
- synfig::Mutex::Lock lock(mutex);
-#endif
- return refcount;
- }
+ { return refcount; }
}; // END of class shared_object
// ========================================================================