trunk/branch integration: RefCountedObject to AtomicCounter

This commit is contained in:
Marian Krivos
2011-08-22 17:49:06 +00:00
parent 422075e485
commit f252f79920

View File

@@ -9,7 +9,7 @@
// //
// Definition of the RefCountedObject class. // Definition of the RefCountedObject class.
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
@@ -41,7 +41,7 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#include "Poco/Mutex.h" #include "Poco/AtomicCounter.h"
namespace Poco { namespace Poco {
@@ -78,8 +78,7 @@ private:
RefCountedObject(const RefCountedObject&); RefCountedObject(const RefCountedObject&);
RefCountedObject& operator = (const RefCountedObject&); RefCountedObject& operator = (const RefCountedObject&);
mutable int _rc; mutable AtomicCounter _counter;
mutable FastMutex _rcMutex;
}; };
@@ -88,7 +87,19 @@ private:
// //
inline int RefCountedObject::referenceCount() const inline int RefCountedObject::referenceCount() const
{ {
return _rc; return _counter.value();
}
inline void RefCountedObject::duplicate() const
{
++_counter;
}
inline void RefCountedObject::release() const
{
if (--_counter == 0) delete this;
} }