diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-05-01 15:09:36 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-05-01 15:09:36 -0500 |
commit | 5faba37f113b6a4d75d7526cbbc1f363a465c39f (patch) | |
tree | 6ac6c5d5b405e8ead8e42e5f1e50b1735cedb070 /src/kernel/qthread_unix.cpp | |
parent | 33e2cf2d1ceff1515b2d7d2a2c29a48de63181b3 (diff) | |
download | tqt3-5faba37f113b6a4d75d7526cbbc1f363a465c39f.tar.gz tqt3-5faba37f113b6a4d75d7526cbbc1f363a465c39f.zip |
Automated update from Qt3
Diffstat (limited to 'src/kernel/qthread_unix.cpp')
-rw-r--r-- | src/kernel/qthread_unix.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/kernel/qthread_unix.cpp b/src/kernel/qthread_unix.cpp index 8cb39a7fc..0d7c657f3 100644 --- a/src/kernel/qthread_unix.cpp +++ b/src/kernel/qthread_unix.cpp @@ -51,10 +51,12 @@ typedef pthread_mutex_t Q_MUTEX_T; #include <errno.h> #include <sched.h> +#if defined(QT_USE_GLIBMAINLOOP) +#include <glib.h> +#endif // QT_USE_GLIBMAINLOOP static TQMutexPool *qt_thread_mutexpool = 0; - #if defined(Q_C_CALLBACKS) extern "C" { #endif @@ -121,6 +123,11 @@ void *TQThreadInstance::start( void *_arg ) { void **arg = (void **) _arg; +#if defined(QT_USE_GLIBMAINLOOP) + // This is the first time we have access to the native pthread ID of this newly created thread + ((TQThreadInstance*)arg[1])->thread_id = pthread_self(); +#endif // QT_USE_GLIBMAINLOOP + setCurrentThread( (TQThread *) arg[0] ); pthread_cleanup_push( TQThreadInstance::finish, arg[1] ); @@ -390,6 +397,20 @@ void TQThread::start(Priority priority) d->args[0] = this; d->args[1] = d; +#if defined(QT_USE_GLIBMAINLOOP) + // Legacy glib versions require this threading system initialization call + g_thread_init(NULL); + + GThread* glib_thread_handle = g_thread_create((GThreadFunc)TQThreadInstance::start, d->args, false, NULL); + if (glib_thread_handle) { + ret = 0; + } + 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) if (ret == EPERM) { @@ -398,6 +419,7 @@ void TQThread::start(Priority priority) } #endif pthread_attr_destroy( &attr ); +#endif // QT_USE_GLIBMAINLOOP if ( ret ) { #ifdef QT_CHECK_STATE @@ -444,8 +466,9 @@ bool TQThread::wait( unsigned long time ) return FALSE; } - if ( d->finished || ! d->running ) + if ( d->finished || ! d->running ) { return TRUE; + } int ret; if (time != ULONG_MAX) { @@ -458,12 +481,15 @@ bool TQThread::wait( unsigned long time ) ti.tv_nsec %= 1000000000; ret = pthread_cond_timedwait(&d->thread_done, &locker.mutex()->d->handle, &ti); - } else + } + else { ret = pthread_cond_wait(&d->thread_done, &locker.mutex()->d->handle); + } #ifdef QT_CHECK_RANGE - if (ret && ret != ETIMEDOUT) + if (ret && ret != ETIMEDOUT) { tqWarning("Wait condition wait failure: %s",strerror(ret)); + } #endif return (ret == 0); |