mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-23 16:03:43 +00:00
Add virtual destructors to fix issues with thread abstraction code.
This commit is contained in:
parent
ed63255514
commit
03b4f16b06
1 changed files with 8 additions and 0 deletions
|
@ -19,6 +19,8 @@ public:
|
||||||
: m_ReferenceCount(1)
|
: m_ReferenceCount(1)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
virtual ~TCThreadBaseImpl() { }
|
||||||
|
|
||||||
void IncreaseReferenceCount() { m_ReferenceCount++; }
|
void IncreaseReferenceCount() { m_ReferenceCount++; }
|
||||||
void DecreaseReferenceCount() { m_ReferenceCount--; }
|
void DecreaseReferenceCount() { m_ReferenceCount--; }
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@ TCThreadBase &TCThreadBase::operator=(const TCThreadBase &other) {
|
||||||
|
|
||||||
TCThreadBase::~TCThreadBase() {
|
TCThreadBase::~TCThreadBase() {
|
||||||
if(m_Impl->GetReferenceCount() <= 1) {
|
if(m_Impl->GetReferenceCount() <= 1) {
|
||||||
|
assert(m_Impl->GetReferenceCount() >= 0);
|
||||||
delete m_Impl;
|
delete m_Impl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +83,7 @@ public:
|
||||||
TCThreadImpl(TCCallable &callable)
|
TCThreadImpl(TCCallable &callable)
|
||||||
: m_Thread(Instance(callable))
|
: m_Thread(Instance(callable))
|
||||||
{ }
|
{ }
|
||||||
|
virtual ~TCThreadImpl() { }
|
||||||
|
|
||||||
void Join() {
|
void Join() {
|
||||||
m_Thread.join();
|
m_Thread.join();
|
||||||
|
@ -121,6 +125,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
boost::mutex &GetMutex() { return m_Mutex; }
|
boost::mutex &GetMutex() { return m_Mutex; }
|
||||||
|
virtual ~TCMutexImpl() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TCMutexImplFactory : public TCThreadBaseImplFactory {
|
class TCMutexImplFactory : public TCThreadBaseImplFactory {
|
||||||
|
@ -148,6 +153,7 @@ public:
|
||||||
TCLockImpl(TCMutex &mutex)
|
TCLockImpl(TCMutex &mutex)
|
||||||
: lock(((TCMutexImpl *)(mutex.m_Impl))->GetMutex())
|
: lock(((TCMutexImpl *)(mutex.m_Impl))->GetMutex())
|
||||||
{ }
|
{ }
|
||||||
|
virtual ~TCLockImpl() { }
|
||||||
|
|
||||||
boost::unique_lock<boost::mutex> &GetLock() { return lock; }
|
boost::unique_lock<boost::mutex> &GetLock() { return lock; }
|
||||||
};
|
};
|
||||||
|
@ -177,6 +183,8 @@ private:
|
||||||
boost::condition_variable m_CV;
|
boost::condition_variable m_CV;
|
||||||
public:
|
public:
|
||||||
TCConditionVariableImpl() { }
|
TCConditionVariableImpl() { }
|
||||||
|
virtual ~TCConditionVariableImpl() { }
|
||||||
|
|
||||||
void Wait(TCLock &lock) {
|
void Wait(TCLock &lock) {
|
||||||
TCLockImpl *lockImpl = (TCLockImpl *)(lock.m_Impl);
|
TCLockImpl *lockImpl = (TCLockImpl *)(lock.m_Impl);
|
||||||
m_CV.wait(lockImpl->GetLock());
|
m_CV.wait(lockImpl->GetLock());
|
||||||
|
|
Loading…
Reference in a new issue