44 #if defined(_OS_HPUX_) 45 #include <sys/pstat.h> 46 #elif defined(_OS_MAC_) 48 #include <CoreServices/CoreServices.h> 49 #elif defined(_OS_BSDI_) 50 #include <mach/mach_types.h> 51 #include <sys/systm.h> 52 #include <sys/types.h> 53 #include <sys/sysctl.h> 79 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
85 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
89 pthread_cleanup_pop(1);
120 if (
d->running)
return;
124 sigset_t sigset, oldset;
125 sigemptyset(&sigset);
126 sigaddset(&sigset, SIGINT);
127 pthread_sigmask(SIG_BLOCK, &sigset, &oldset);
133 pthread_attr_init(&attr);
134 pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
135 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
138 #if defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0>0) 139 pthread_attr_setstacksize(&attr,
d->stackSize);
143 pthread_attr_destroy(&attr);
147 qWarning(
"QThread::start: Thread creation error: %d", code);
156 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
164 if (!
d->thread_id)
return;
166 int code = pthread_cancel(
d->thread_id);
169 qWarning(
"QThread::start: Thread termination error: %d", code);
173 d->terminated =
TRUE;
180 if (
d->finished || !
d->running)
return;
184 d->thread_done.wait(locker.
mutex());
188 #if defined(QT_LINUXBASE) && !defined(_SC_NPROCESSORS_ONLN) 190 # define _SC_NPROCESSORS_ONLN 84 196 #if defined(_OS_MAC_) 198 cores = (
int)MPProcessorsScheduled();
199 #elif defined(_OS_HPUX_) 201 struct pst_dynamic psd;
202 if (pstat_getdynamic(&psd,
sizeof(psd), 1, 0) == -1)
204 perror(
"pstat_getdynamic");
209 cores = (
int)psd.psd_proc_cnt;
211 #elif defined(_OS_BSDI_) 213 size_t len =
sizeof(cores);
218 if (sysctl(mib, 2, &cores, &len, NULL, 0) != 0)
223 #elif defined(_OS_IRIX_) 225 cores = (
int)sysconf(_SC_NPROC_ONLN);
228 cores = (
int)sysconf(_SC_NPROCESSORS_ONLN);
static void * start(void *arg)
static void finish(void *arg)
void qWarning(const char *msg,...)
virtual void terminated()
CodeOutputInterface * code
QWaitCondition thread_done
static int idealThreadCount()