mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-15 23:20:06 +02:00
trunk/branch integration: RefCountedObject to AtomicCounter
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user