From 03b4f16b06dfa38579788212ceabdbe1876bc754 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sun, 30 Sep 2012 13:45:55 -0400 Subject: [PATCH] Add virtual destructors to fix issues with thread abstraction code. --- Core/src/ThreadBoost.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Core/src/ThreadBoost.cpp b/Core/src/ThreadBoost.cpp index eb24d38..1dcceb2 100644 --- a/Core/src/ThreadBoost.cpp +++ b/Core/src/ThreadBoost.cpp @@ -19,6 +19,8 @@ public: : m_ReferenceCount(1) { } + virtual ~TCThreadBaseImpl() { } + void IncreaseReferenceCount() { m_ReferenceCount++; } void DecreaseReferenceCount() { m_ReferenceCount--; } @@ -52,6 +54,7 @@ TCThreadBase &TCThreadBase::operator=(const TCThreadBase &other) { TCThreadBase::~TCThreadBase() { if(m_Impl->GetReferenceCount() <= 1) { + assert(m_Impl->GetReferenceCount() >= 0); delete m_Impl; } } @@ -80,6 +83,7 @@ public: TCThreadImpl(TCCallable &callable) : m_Thread(Instance(callable)) { } + virtual ~TCThreadImpl() { } void Join() { m_Thread.join(); @@ -121,6 +125,7 @@ private: public: boost::mutex &GetMutex() { return m_Mutex; } + virtual ~TCMutexImpl() { } }; class TCMutexImplFactory : public TCThreadBaseImplFactory { @@ -148,6 +153,7 @@ public: TCLockImpl(TCMutex &mutex) : lock(((TCMutexImpl *)(mutex.m_Impl))->GetMutex()) { } + virtual ~TCLockImpl() { } boost::unique_lock &GetLock() { return lock; } }; @@ -177,6 +183,8 @@ private: boost::condition_variable m_CV; public: TCConditionVariableImpl() { } + virtual ~TCConditionVariableImpl() { } + void Wait(TCLock &lock) { TCLockImpl *lockImpl = (TCLockImpl *)(lock.m_Impl); m_CV.wait(lockImpl->GetLock());