Add SharedArg and AsyncObject

This commit is contained in:
Vinnie Falco
2013-09-20 16:44:04 -07:00
parent 373ca9cef0
commit 1a3cddc002
7 changed files with 257 additions and 14 deletions

View File

@@ -20,10 +20,10 @@
namespace detail
{
class LeakCheckedBase::CounterBase::Singleton
class LeakCheckedBase::LeakCounterBase::Singleton
{
public:
void push_back (CounterBase* counter)
void push_back (LeakCounterBase* counter)
{
m_list.push_front (counter);
}
@@ -32,7 +32,7 @@ public:
{
for (;;)
{
CounterBase* const counter = m_list.pop_front ();
LeakCounterBase* const counter = m_list.pop_front ();
if (!counter)
break;
@@ -51,17 +51,17 @@ public:
private:
friend class LeakCheckedBase;
LockFreeStack <CounterBase> m_list;
LockFreeStack <LeakCounterBase> m_list;
};
//------------------------------------------------------------------------------
LeakCheckedBase::CounterBase::CounterBase ()
LeakCheckedBase::LeakCounterBase::LeakCounterBase ()
{
Singleton::getInstance ().push_back (this);
}
void LeakCheckedBase::CounterBase::checkForLeaks ()
void LeakCheckedBase::LeakCounterBase::checkForLeaks ()
{
// If there's a runtime error from this line, it means there's
// an order of destruction problem between different translation units!
@@ -120,7 +120,7 @@ void LeakCheckedBase::reportDanglingPointer (char const*)
void LeakCheckedBase::checkForLeaks ()
{
CounterBase::Singleton::getInstance ().checkForLeaks ();
LeakCounterBase::Singleton::getInstance ().checkForLeaks ();
}
}

View File

@@ -29,12 +29,12 @@ public:
static void checkForLeaks ();
protected:
class CounterBase : public LockFreeStack <CounterBase>::Node
class LeakCounterBase : public LockFreeStack <LeakCounterBase>::Node
{
public:
CounterBase ();
LeakCounterBase ();
virtual ~CounterBase ()
virtual ~LeakCounterBase ()
{
}
@@ -95,10 +95,10 @@ protected:
private:
// Singleton that maintains the count of this object
//
class Counter : public CounterBase
class LeakCounter : public LeakCounterBase
{
public:
Counter () noexcept
LeakCounter () noexcept
{
}
@@ -123,9 +123,9 @@ private:
// Retrieve the singleton for this object
//
static Counter& getCounter () noexcept
static LeakCounter& getCounter () noexcept
{
return StaticObject <Counter>::get();
return StaticObject <LeakCounter>::get();
}
};