From 9a4765a62e321af08ec96a03cdbef64039788e86 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 14 May 2013 19:35:54 -0500 Subject: Automated update from Qt3 --- src/kernel/qthread_unix.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src/kernel/qthread_unix.cpp') diff --git a/src/kernel/qthread_unix.cpp b/src/kernel/qthread_unix.cpp index 0d7c657f3..13c820e23 100644 --- a/src/kernel/qthread_unix.cpp +++ b/src/kernel/qthread_unix.cpp @@ -47,6 +47,7 @@ typedef pthread_mutex_t Q_MUTEX_T; #include #include #include +#include #include #include @@ -109,6 +110,7 @@ void TQThreadInstance::init(unsigned int stackSize) thread_id = 0; eventLoop = 0; + cleanupType = TQThread::CleanupMergeObjects; // threads have not been initialized yet, do it now if (! qt_thread_mutexpool) TQThread::initialize(); @@ -150,6 +152,8 @@ void TQThreadInstance::finish( void * ) return; } + TQApplication::threadTerminationHandler((TQThread*)d->args[0]); + TQMutexLocker locker( d->mutex() ); d->running = FALSE; d->finished = TRUE; @@ -179,7 +183,6 @@ void TQThreadInstance::terminate() pthread_cancel( thread_id ); } - /************************************************************************** ** TQThread *************************************************************************/ @@ -398,6 +401,9 @@ void TQThread::start(Priority priority) d->args[0] = this; d->args[1] = d; #if defined(QT_USE_GLIBMAINLOOP) + // The correct thread_id is set in TQThreadInstance::start using the value of d->args[1] + d->thread_id = NULL; + // Legacy glib versions require this threading system initialization call g_thread_init(NULL); @@ -408,8 +414,6 @@ void TQThread::start(Priority priority) else { ret = -1; } - // The correct thread_id is set in TQThreadInstance::start using the value of d->args[1] - d->thread_id = NULL; #else // QT_USE_GLIBMAINLOOP ret = pthread_create( &d->thread_id, &attr, (TQtThreadCallback)TQThreadInstance::start, d->args ); #if defined (Q_OS_HPUX) @@ -495,6 +499,36 @@ bool TQThread::wait( unsigned long time ) return (ret == 0); } +/*! + Returns the current cleanup behaviour of the thread. + + \sa setCleanupType + \sa CleanupType +*/ + +TQThread::CleanupType TQThread::cleanupType() { + return (TQThread::CleanupType)d->cleanupType; +} + +/*! + Sets the current cleanup behaviour of the thread. The default, + TQThread::CleanupMergeObjects, will merge any objects owned by this thread + with the main GUI thread when this thread is terminated. + + If faster thread termination performance is desired, TQThread::CleanupNone + may be specified instead. However, this is not recommended as any objects + owned by this thread on termination can then cause events to become "stuck" + in the global event queue, leading to high CPU usage and other undesirable + behavior. You have been warned! + + \sa cleanupType + \sa CleanupType +*/ + +void TQThread::setCleanupType(CleanupType type) { + d->cleanupType = type; +} + /*! Returns a pointer to the currently executing TQThread. If the current thread was not started using the TQThread API, this -- cgit v1.2.1