Skip to content
Snippets Groups Projects
Commit 7510e92c authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2:
Browse files

Include RCBase

parent 5829c0da
No related branches found
No related tags found
No related merge requests found
Pipeline #6555990 canceled
......@@ -21,30 +21,35 @@
#include <atomic>
class RCBase
{
class RCBase {
public:
RCBase() = default;
// Increase the reference count
void ref () const;
void ref() const {
++m_count;
}
// Decreases the reference count. When the reference count
// falls to zero, the object deletes itself.
void unref () const;
void unref () const {
if (--m_count == 0) delete this;
}
// Return the reference count.
unsigned int refCount () const;
unsigned int refCount () const {
return m_count.load();
}
protected:
virtual ~RCBase() = default;
virtual ~RCBase() = default;
private:
RCBase(const RCBase &right) = delete;
RCBase & operator=(const RCBase &right) = delete;
RCBase(const RCBase &right) = delete;
RCBase & operator=(const RCBase &right) = delete;
// The reference count
mutable std::atomic<unsigned> m_count{0};
// The reference count
mutable std::atomic<unsigned> m_count{0};
};
......
......@@ -11,19 +11,11 @@
const std::string GeoShapeIntersection::s_classType = "Intersection";
const ShapeType GeoShapeIntersection::s_classTypeID = 0x00;
GeoShapeIntersection::GeoShapeIntersection (const GeoShape* A, const GeoShape* B)
: m_opA (A)
, m_opB (B)
{
m_opA->ref ();
m_opB->ref ();
}
GeoShapeIntersection::GeoShapeIntersection (const GeoShape* A,
const GeoShape* B) :
m_opA (A) , m_opB (B) {}
GeoShapeIntersection::~GeoShapeIntersection()
{
m_opA->unref ();
m_opB->unref ();
}
double GeoShapeIntersection::volume () const
{
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelKernel/RCBase.h"
#include <exception>
void RCBase::ref () const {
++m_count;
}
void RCBase::unref () const
{
if (--m_count == 0) delete this;
}
unsigned int RCBase::refCount () const
{
return m_count.load();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment