|
|
@ -20,7 +20,7 @@
|
|
|
|
#ifndef _smart_pointer_hpp
|
|
|
|
#ifndef _smart_pointer_hpp
|
|
|
|
#define _smart_pointer_hpp
|
|
|
|
#define _smart_pointer_hpp
|
|
|
|
|
|
|
|
|
|
|
|
#if defined TQT_THREAD_SUPPORT
|
|
|
|
#if defined QT_THREAD_SUPPORT
|
|
|
|
#include "tqmutex.h"
|
|
|
|
#include "tqmutex.h"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
@ -41,27 +41,27 @@ class ref_count {
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
//! reference count member
|
|
|
|
//! reference count member
|
|
|
|
long m_RefCount;
|
|
|
|
long m_RefCount;
|
|
|
|
#ifdef TQT_THREAD_SUPPORT
|
|
|
|
#ifdef QT_THREAD_SUPPORT
|
|
|
|
TQMutex m_RefcountMutex;
|
|
|
|
TQMutex m_RefcountMutex;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
//! first reference must be added after "new" via Pointer()
|
|
|
|
//! first reference must be added after "new" via Pointer()
|
|
|
|
ref_count() : m_RefCount(0)
|
|
|
|
ref_count() : m_RefCount(0)
|
|
|
|
#ifdef TQT_THREAD_SUPPORT
|
|
|
|
#ifdef QT_THREAD_SUPPORT
|
|
|
|
,m_RefcountMutex()
|
|
|
|
,m_RefcountMutex()
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
{}
|
|
|
|
virtual ~ref_count() {}
|
|
|
|
virtual ~ref_count() {}
|
|
|
|
//! add a reference
|
|
|
|
//! add a reference
|
|
|
|
void Incr() {
|
|
|
|
void Incr() {
|
|
|
|
#ifdef TQT_THREAD_SUPPORT
|
|
|
|
#ifdef QT_THREAD_SUPPORT
|
|
|
|
TQMutexLocker a(&m_RefcountMutex);
|
|
|
|
TQMutexLocker a(&m_RefcountMutex);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
++m_RefCount;
|
|
|
|
++m_RefCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//! delete a reference
|
|
|
|
//! delete a reference
|
|
|
|
bool Decr() {
|
|
|
|
bool Decr() {
|
|
|
|
#ifdef TQT_THREAD_SUPPORT
|
|
|
|
#ifdef QT_THREAD_SUPPORT
|
|
|
|
TQMutexLocker a(&m_RefcountMutex);
|
|
|
|
TQMutexLocker a(&m_RefcountMutex);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
--m_RefCount;
|
|
|
|
--m_RefCount;
|
|
|
|