summaryrefslogtreecommitdiffstats
path: root/src/tsthread/tsthread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tsthread/tsthread.h')
-rw-r--r--src/tsthread/tsthread.h169
1 files changed, 85 insertions, 84 deletions
diff --git a/src/tsthread/tsthread.h b/src/tsthread/tsthread.h
index 5b98890..91b64e6 100644
--- a/src/tsthread/tsthread.h
+++ b/src/tsthread/tsthread.h
@@ -25,15 +25,15 @@ DEALINGS IN THE SOFTWARE.
#ifndef TSTHREAD_H
#define TSTHREAD_H
-#include <qobject.h>
-#include <qthread.h>
-#include <qwaitcondition.h>
-#include <qdeepcopy.h>
-#include <qmutex.h>
-#include <private/qucomextra_p.h>
-
-#ifdef TS_QTHREADSTORAGE
-#include <qthreadstorage.h>
+#include <tqobject.h>
+#include <tqthread.h>
+#include <tqwaitcondition.h>
+#include <tqdeepcopy.h>
+#include <tqmutex.h>
+#include <tqucomextra_p.h>
+
+#ifdef TS_TQTHREADSTORAGE
+#include <tqthreadstorage.h>
#else
#include <pthread.h>
#endif
@@ -44,42 +44,43 @@ DEALINGS IN THE SOFTWARE.
template< typename T >
T TSDeepCopy( const T& t )
{
- return QDeepCopy< T >( t );
+ return TQDeepCopy< T >( t );
}
class TSCurrentThread;
/**
- Thread class, internally based on QThread, which intentionally doesn't have
- dangerous crap like QThread::terminate() and intentionally has useful features
+ Thread class, internally based on TQThread, which intentionally doesn't have
+ dangerous crap like TQThread::terminate() and intentionally has useful features
like emitting signals to the main thread, currentThread() or support
for cancelling.
*/
class TSThread
- : public QObject
+ : public TQObject
{
Q_OBJECT
+ TQ_OBJECT
public:
TSThread();
virtual ~TSThread();
/**
* Starts the thread.
- * @see QThread::start()
+ * @see TQThread::start()
*/
void start();
/**
* Waits for the thread to finish.
- * @see QThread::wait()
+ * @see TQThread::wait()
*/
void wait( unsigned long time = ULONG_MAX );
/**
* Returns true if the thread has finished.
- * @see QThread::finished()
+ * @see TQThread::finished()
*/
bool finished() const;
/**
* Returns true if the thread is running.
- * @see QThread::running()
+ * @see TQThread::running()
*/
bool running() const;
/**
@@ -108,44 +109,44 @@ class TSThread
* Emits the specified signal in the main thread. This function returns
* only after all slots connected to the signal have been executed (i.e.
* it works like normal signal). The signal can have one pointer argument,
- * which can be used for communication in either direction. QObject::sender()
+ * which can be used for communication in either direction. TQObject::sender()
* in slots is valid.
* Example:
* \code
- * emitSignal( this, SIGNAL( result( int* )), &result_data );
+ * emitSignal( this, TQT_SIGNAL( result( int* )), &result_data );
* \endcode
* @see postSignal
* @see emitCancellableSignal
*/
- void emitSignal( QObject* obj, const char* signal );
+ void emitSignal( TQObject* obj, const char* signal );
template< typename T1 >
- void emitSignal( QObject* obj, const char* signal, const T1& p1 );
+ void emitSignal( TQObject* obj, const char* signal, const T1& p1 );
template< typename T1, typename T2 >
- void emitSignal( QObject* obj, const char* signal, const T1& p1, const T2& p2 );
+ void emitSignal( TQObject* obj, const char* signal, const T1& p1, const T2& p2 );
/**
* This function works like emitSignal(), but additionally acts as a cancellation
* point, i.e. calling cancel() on the thread causes premature return.
* @see emitSignal
* @see postSignal
*/
- void emitCancellableSignal( QObject* obj, const char* signal );
+ void emitCancellableSignal( TQObject* obj, const char* signal );
template< typename T1 >
- void emitCancellableSignal( QObject* obj, const char* signal, const T1& p1 );
+ void emitCancellableSignal( TQObject* obj, const char* signal, const T1& p1 );
template< typename T1, typename T2 >
- void emitCancellableSignal( QObject* obj, const char* signal, const T1& p1, const T2& p2 );
+ void emitCancellableSignal( TQObject* obj, const char* signal, const T1& p1, const T2& p2 );
/**
* Posts (i.e. it is not executed immediatelly like normal signals)
* a signal to be emitted in the main thread. The signal cannot
* have any parameters, use your TSThread derived class instance
- * data members instead. QObject::sender() in slots is valid, unless
+ * data members instead. TQObject::sender() in slots is valid, unless
* the thread instance is destroyed before the signal is processed.
* @see emitSignal
*/
- void postSignal( QObject* obj, const char* signal ); // is emitted _always_ in main thread
+ void postSignal( TQObject* obj, const char* signal ); // is emitted _always_ in main thread
protected:
/**
* The code to be executed in the started thread.
- * @see QThread::run()
+ * @see TQThread::run()
*/
virtual void run() = 0;
signals:
@@ -157,25 +158,25 @@ class TSThread
/**
* @internal
*/
- void customEvent( QCustomEvent* e );
+ void customEvent( TQCustomEvent* e );
private:
class SignalEvent
- : public QCustomEvent
+ : public TQCustomEvent
{
public:
- SignalEvent( const char* sig, QObject* obj, QUObject* o )
- : QCustomEvent( QEvent::User ), signal( sig ), object( obj ), args( o )
+ SignalEvent( const char* sig, TQObject* obj, TQUObject* o )
+ : TQCustomEvent( TQEvent::User ), signal( sig ), object( obj ), args( o )
{
}
- const QCString signal;
- QObject* object;
- QUObject* args;
+ const TQCString signal;
+ TQObject* object;
+ TQUObject* args;
};
class Helper
- : public QThread
+ : public TQThread
{
public:
- Helper( TSThread* parent );
+ Helper( TSThread* tqparent );
protected:
virtual void run();
private:
@@ -183,29 +184,29 @@ class TSThread
};
void executeThread();
static void initCurrentThread();
- bool setCancelData( QMutex*m, QWaitCondition* c );
- void setSignalData( QUObject* o, int i );
- void setSignalData( QUObject* o, const QImage& i );
- void setSignalData( QUObject* o, const QString& s );
- void setSignalData( QUObject* o, bool b );
- void setSignalData( QUObject* o, const QColor& c );
- void setSignalData( QUObject* o, const char* s );
- void setSignalData( QUObject* o, const QSize& );
- void emitSignalInternal( QObject* obj, const char* signal, QUObject* o );
- void emitCancellableSignalInternal( QObject* obj, const char* signal, QUObject* o );
+ bool setCancelData( TQMutex*m, TQWaitCondition* c );
+ void setSignalData( TQUObject* o, int i );
+ void setSignalData( TQUObject* o, const TQImage& i );
+ void setSignalData( TQUObject* o, const TQString& s );
+ void setSignalData( TQUObject* o, bool b );
+ void setSignalData( TQUObject* o, const TQColor& c );
+ void setSignalData( TQUObject* o, const char* s );
+ void setSignalData( TQUObject* o, const TQSize& );
+ void emitSignalInternal( TQObject* obj, const char* signal, TQUObject* o );
+ void emitCancellableSignalInternal( TQObject* obj, const char* signal, TQUObject* o );
friend class Helper;
friend class TSWaitCondition;
Helper thread;
bool cancelling;
bool emit_pending;
- mutable QMutex mutex;
- QMutex signal_mutex;
+ mutable TQMutex mutex;
+ TQMutex signal_mutex;
TSWaitCondition signal_cond;
- QMutex* cancel_mutex;
- QWaitCondition* cancel_cond;
+ TQMutex* cancel_mutex;
+ TQWaitCondition* cancel_cond;
bool* deleted_flag;
-#ifdef TS_QTHREADSTORAGE
- static QThreadStorage< TSThread** >* current_thread;
+#ifdef TS_TQTHREADSTORAGE
+ static TQThreadStorage< TSThread** >* current_thread;
#else
static TSCurrentThread* current_thread;
#endif
@@ -215,7 +216,7 @@ class TSThread
TSThread& operator=( const TSThread& );
};
-#ifndef TS_QTHREADSTORAGE
+#ifndef TS_TQTHREADSTORAGE
/**
* @internal
*/
@@ -255,15 +256,15 @@ inline TSThread* TSCurrentThread::localData() const
inline
bool TSThread::testCancel() const
{
- QMutexLocker lock( &mutex );
+ TQMutexLocker lock( &mutex );
return cancelling;
}
#include <kdebug.h>
inline
-bool TSThread::setCancelData( QMutex* m, QWaitCondition* c )
+bool TSThread::setCancelData( TQMutex* m, TQWaitCondition* c )
{
- QMutexLocker lock( &mutex );
+ TQMutexLocker lock( &mutex );
if( cancelling && m != NULL )
return false;
cancel_mutex = m;
@@ -276,7 +277,7 @@ TSThread* TSThread::currentThread()
{
if( current_thread == NULL )
initCurrentThread();
-#ifdef TS_QTHREADSTORAGE
+#ifdef TS_TQTHREADSTORAGE
return *current_thread->localData();
#else
return current_thread->localData();
@@ -290,94 +291,94 @@ TSThread* TSThread::mainThread()
}
inline
-void TSThread::setSignalData( QUObject* o, int i )
+void TSThread::setSignalData( TQUObject* o, int i )
{
- static_QUType_int.set( o, i );
+ static_TQUType_int.set( o, i );
}
inline
-void TSThread::setSignalData( QUObject* o, const QImage& i )
+void TSThread::setSignalData( TQUObject* o, const TQImage& i )
{
- static_QUType_varptr.set( o, &i );
+ static_TQUType_varptr.set( o, &i );
}
inline
-void TSThread::setSignalData( QUObject* o, const QString& s )
+void TSThread::setSignalData( TQUObject* o, const TQString& s )
{
- static_QUType_QString.set( o, s );
+ static_TQUType_TQString.set( o, s );
}
inline
-void TSThread::setSignalData( QUObject* o, bool b )
+void TSThread::setSignalData( TQUObject* o, bool b )
{
- static_QUType_bool.set( o, b );
+ static_TQUType_bool.set( o, b );
}
inline
-void TSThread::setSignalData( QUObject* o, const QColor& c )
+void TSThread::setSignalData( TQUObject* o, const TQColor& c )
{
- static_QUType_varptr.set( o, &c );
+ static_TQUType_varptr.set( o, &c );
}
inline
-void TSThread::setSignalData( QUObject* o, const char* s )
+void TSThread::setSignalData( TQUObject* o, const char* s )
{
- static_QUType_charstar.set( o, s );
+ static_TQUType_charstar.set( o, s );
}
inline
-void TSThread::setSignalData( QUObject* o, const QSize& s )
+void TSThread::setSignalData( TQUObject* o, const TQSize& s )
{
- static_QUType_varptr.set( o, &s );
+ static_TQUType_varptr.set( o, &s );
}
inline
-void TSThread::emitSignal( QObject* obj, const char* signal )
+void TSThread::emitSignal( TQObject* obj, const char* signal )
{
- QUObject o[ 1 ];
+ TQUObject o[ 1 ];
emitSignalInternal( obj, signal, o );
}
template< typename T1 >
inline
-void TSThread::emitSignal( QObject* obj, const char* signal, const T1& p1 )
+void TSThread::emitSignal( TQObject* obj, const char* signal, const T1& p1 )
{
- QUObject o[ 2 ];
+ TQUObject o[ 2 ];
setSignalData( o + 1, p1 );
emitSignalInternal( obj, signal, o );
}
template< typename T1, typename T2 >
inline
-void TSThread::emitSignal( QObject* obj, const char* signal, const T1& p1, const T2& p2 )
+void TSThread::emitSignal( TQObject* obj, const char* signal, const T1& p1, const T2& p2 )
{
- QUObject o[ 3 ];
+ TQUObject o[ 3 ];
setSignalData( o + 1, p1 );
setSignalData( o + 2, p2 );
emitSignalInternal( obj, signal, o );
}
inline
-void TSThread::emitCancellableSignal( QObject* obj, const char* signal )
+void TSThread::emitCancellableSignal( TQObject* obj, const char* signal )
{
- QUObject o[ 1 ];
+ TQUObject o[ 1 ];
emitCancellableSignalInternal( obj, signal, o );
}
template< typename T1 >
inline
-void TSThread::emitCancellableSignal( QObject* obj, const char* signal, const T1& p1 )
+void TSThread::emitCancellableSignal( TQObject* obj, const char* signal, const T1& p1 )
{
- QUObject o[ 2 ];
+ TQUObject o[ 2 ];
setSignalData( o + 1, p1 );
emitCancellableSignalInternal( obj, signal, o );
}
template< typename T1, typename T2 >
inline
-void TSThread::emitCancellableSignal( QObject* obj, const char* signal, const T1& p1, const T2& p2 )
+void TSThread::emitCancellableSignal( TQObject* obj, const char* signal, const T1& p1, const T2& p2 )
{
- QUObject o[ 3 ];
+ TQUObject o[ 3 ];
setSignalData( o + 1, p1 );
setSignalData( o + 2, p2 );
emitCancellableSignalInternal( obj, signal, o );