- Timestamp:
- Jul 4, 2009, 2:31:20 PM (16 years ago)
- Location:
- trunk/src/corelib/thread
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/thread/qthread.cpp
r2 r69 154 154 terminationEnabled = true; 155 155 terminatePending = false; 156 157 158 159 156 160 #endif 157 161 … … 550 554 Initializes the QThread system. 551 555 */ 552 #if defined (Q_OS_WIN)556 #if defined) 553 557 void qt_create_tls(); 554 558 #endif … … 560 564 qt_global_mutexpool = QMutexPool::instance(); 561 565 562 #if defined (Q_OS_WIN)566 #if defined) 563 567 qt_create_tls(); 564 568 #endif -
trunk/src/corelib/thread/qthread_os2.cpp
r63 r69 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** Contact: Qt Software Information ([email protected]) 5 6 5 7 ** 6 8 ** This file is part of the QtCore module of the Qt Toolkit. … … 40 42 ****************************************************************************/ 41 43 42 //#define WINVER 0x050043 #define _WIN32_WINNT 0x040044 45 46 44 #include "qthread.h" 47 45 #include "qthread_p.h" … … 53 51 54 52 #include <private/qcoreapplication_p.h> 55 #include <private/qeventdispatcher_win_p.h> 56 57 #include <windows.h> 58 59 60 #ifndef Q_OS_WINCE 61 #ifndef _MT 62 #define _MT 63 #endif 64 #include <process.h> 65 #else 66 #include "qfunctions_wince.h" 67 #endif 53 #include <private/qeventdispatcher_pm_p.h> 54 55 #include <qt_os2.h> 68 56 69 57 #ifndef QT_NO_THREAD 58 70 59 QT_BEGIN_NAMESPACE 71 60 72 void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread); 73 void qt_adopted_thread_watcher_function(void *); 74 75 static DWORD qt_current_thread_data_tls_index = TLS_OUT_OF_INDEXES; 76 void qt_create_tls() 77 { 78 if (qt_current_thread_data_tls_index != TLS_OUT_OF_INDEXES) 61 static void qt_watch_adopted_thread(const TID adoptedTID, QThread *qthread); 62 static void qt_adopted_thread_watcher_function(void *); 63 64 static QThreadData **qt_tls = NULL; 65 66 static void qt_create_tls() 67 { 68 if (qt_tls != NULL) 79 69 return; 80 70 static QMutex mutex; 81 71 QMutexLocker locker(&mutex); 82 qt_current_thread_data_tls_index = TlsAlloc(); 72 APIRET rc = DosAllocThreadLocalMemory((sizeof(QThreadData *) + 3)/4, 73 (PULONG *)&qt_tls); 74 if (rc != NO_ERROR) 75 qWarning("qt_create_tls: DosAllocThreadLocalMemory returned %lu", rc); 83 76 } 84 77 85 78 static void qt_free_tls() 86 79 { 87 if (qt_current_thread_data_tls_index != TLS_OUT_OF_INDEXES) { 88 TlsFree(qt_current_thread_data_tls_index); 89 qt_current_thread_data_tls_index = TLS_OUT_OF_INDEXES; 90 } 91 } 92 Q_DESTRUCTOR_FUNCTION(qt_free_tls) 80 if (qt_tls != NULL) { 81 DosFreeThreadLocalMemory((PULONG)qt_tls); 82 qt_tls = NULL; 83 } 84 } 85 86 static Q_DESTRUCTOR_FUNCTION(qt_free_tls) 93 87 94 88 /* … … 98 92 { 99 93 qt_create_tls(); 100 QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index));94 QThreadData *threadData = ; 101 95 if (!threadData) { 102 96 QThread *adopted = 0; … … 104 98 Q_ASSERT(adopted); 105 99 threadData = QThreadData::get2(adopted); 106 TlsSetValue(qt_current_thread_data_tls_index, threadData);100 ; 107 101 adopted->d_func()->running = true; 108 102 adopted->d_func()->finished = false; … … 112 106 // This needs to be called prior to new AdoptedThread() to 113 107 // avoid recursion. 114 TlsSetValue(qt_current_thread_data_tls_index, threadData);108 ; 115 109 threadData->thread = new QAdoptedThread(threadData); 116 110 threadData->deref(); … … 120 114 QCoreApplicationPrivate::theMainThread = threadData->thread; 121 115 } else { 122 HANDLE realHandle = INVALID_HANDLE_VALUE; 123 #if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600)) 124 DuplicateHandle(GetCurrentProcess(), 125 GetCurrentThread(), 126 GetCurrentProcess(), 127 &realHandle, 128 0, 129 FALSE, 130 DUPLICATE_SAME_ACCESS); 131 #else 132 realHandle = (HANDLE)GetCurrentThreadId(); 133 #endif 134 qt_watch_adopted_thread(realHandle, threadData->thread); 116 PTIB ptib; 117 DosGetInfoBlocks(&ptib, NULL); 118 qt_watch_adopted_thread(ptib->tib_ptib2->tib2_ultid, threadData->thread); 135 119 } 136 120 } … … 140 124 void QAdoptedThread::init() 141 125 { 142 d_func()->handle = GetCurrentThread(); 143 d_func()->id = GetCurrentThreadId(); 144 } 145 146 static QVector<HANDLE> qt_adopted_thread_handles; 126 PTIB ptib; 127 DosGetInfoBlocks(&ptib, NULL); 128 d_func()->tid = ptib->tib_ptib2->tib2_ultid; 129 } 130 131 static QVector<TID> qt_adopted_thread_tids; 147 132 static QVector<QThread *> qt_adopted_qthreads; 148 133 static QMutex qt_adopted_thread_watcher_mutex; 149 static HANDLE qt_adopted_thread_watcher_handle= 0;150 static H ANDLE qt_adopted_thread_wakeup = 0;134 static = 0; 135 static H; 151 136 152 137 /*! \internal … … 155 140 thread if necessary. 156 141 */ 157 void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)142 , QThread *qthread) 158 143 { 159 144 QMutexLocker lock(&qt_adopted_thread_watcher_mutex); 160 qt_adopted_thread_ handles.append(adoptedThreadHandle);145 qt_adopted_thread_); 161 146 qt_adopted_qthreads.append(qthread); 162 147 163 148 // Start watcher thread if it is not already running. 164 if (qt_adopted_thread_watcher_handle == 0) { 165 if (qt_adopted_thread_wakeup == 0) { 166 qt_adopted_thread_wakeup = QT_WA_INLINE(CreateEventW(0, false, false, 0), 167 CreateEventA(0, false, false, 0)); 168 qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup); 149 if (qt_adopted_thread_watcher_tid == 0) { 150 APIRET rc = DosCreateEventSem(NULL, &qt_adopted_thread_wakeup, 151 DCE_AUTORESET, FALSE); 152 if (rc != NO_ERROR) { 153 qWarning("qt_watch_adopted_thread: DosCreateEventSem returned %lu", rc); 154 return; 169 155 } 170 156 171 qt_adopted_thread_watcher_handle = 172 (HANDLE)_beginthread(qt_adopted_thread_watcher_function, 0, NULL); 157 int tid = 158 (TID)_beginthread(qt_adopted_thread_watcher_function, NULL, 0, NULL); 159 if (tid == -1) 160 qErrnoWarning(errno, "qt_watch_adopted_thread: _beginthread failed"); 161 else 162 qt_adopted_thread_watcher_tid = (TID) tid; 173 163 } else { 174 SetEvent(qt_adopted_thread_wakeup);164 (qt_adopted_thread_wakeup); 175 165 } 176 166 } … … 181 171 to make sure it gets cleaned up properly. 182 172 */ 183 void qt_adopted_thread_watcher_function(void *)173 void qt_adopted_thread_watcher_function(void *) 184 174 { 185 175 forever { 186 176 qt_adopted_thread_watcher_mutex.lock(); 187 177 188 if (qt_adopted_thread_handles.count() == 1) { 189 qt_adopted_thread_watcher_handle = 0; 178 if (qt_adopted_thread_tids.isEmpty()) { 179 // our service is no longer necessary 180 qt_adopted_thread_watcher_tid = 0; 181 DosCloseEventSem(qt_adopted_thread_wakeup); 182 qt_adopted_thread_wakeup = NULLHANDLE; 190 183 qt_adopted_thread_watcher_mutex.unlock(); 191 184 break; 192 185 } 193 186 194 QVector<HANDLE> handlesCopy = qt_adopted_thread_handles; 187 APIRET rc; 188 TID tid; 189 190 for (int i = 0; i < qt_adopted_thread_tids.size();) { 191 tid = qt_adopted_thread_tids.at(i); 192 rc = DosWaitThread(&tid, DCWW_NOWAIT); 193 if (rc != ERROR_THREAD_NOT_TERMINATED) { 194 if (rc == NO_ERROR || rc == ERROR_INVALID_THREADID) { 195 QThreadData::get2(qt_adopted_qthreads.at(i))->deref(); 196 QMutexLocker lock(&qt_adopted_thread_watcher_mutex); 197 qt_adopted_thread_tids.remove(i); 198 qt_adopted_qthreads.remove(i); 199 continue; 200 } 201 qWarning("qt_adopted_thread_watcher_function: DosWaitThread returned %lu", rc); 202 } 203 ++i; 204 } 205 195 206 qt_adopted_thread_watcher_mutex.unlock(); 196 207 197 DWORD ret = WAIT_TIMEOUT; 198 int loops = (handlesCopy.count() / MAXIMUM_WAIT_OBJECTS) + 1, offset, count; 199 if (loops == 1) { 200 // no need to loop, no timeout 201 offset = 0; 202 count = handlesCopy.count(); 203 ret = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, INFINITE); 204 } else { 205 int loop = 0; 206 do { 207 offset = loop * MAXIMUM_WAIT_OBJECTS; 208 count = qMin(handlesCopy.count() - offset, MAXIMUM_WAIT_OBJECTS); 209 ret = WaitForMultipleObjects(count, handlesCopy.constData() + offset, false, 100); 210 loop = (loop + 1) % loops; 211 } while (ret == WAIT_TIMEOUT); 208 rc = DosWaitEventSem(qt_adopted_thread_wakeup, 300); 209 if (rc != NO_ERROR && rc != ERROR_TIMEOUT) { 210 qWarning("qt_adopted_thread_watcher_function: DosWaitEventSem returned %lu", rc); 212 211 } 213 214 if (ret == WAIT_FAILED || !(ret >= WAIT_OBJECT_0 && ret < WAIT_OBJECT_0 + uint(count))) { 215 qWarning("QThread internal error while waiting for adopted threads: %d", int(GetLastError())); 216 continue; 217 } 218 219 const int handleIndex = offset + ret - WAIT_OBJECT_0; 220 if (handleIndex == 0){ 221 // New handle to watch was added. 222 continue; 223 } else { 224 // printf("(qt) - qt_adopted_thread_watcher_function... called\n"); 225 const int qthreadIndex = handleIndex - 1; 226 QThreadData::get2(qt_adopted_qthreads.at(qthreadIndex))->deref(); 227 #if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600)) 228 CloseHandle(qt_adopted_thread_handles.at(handleIndex)); 229 #endif 230 QMutexLocker lock(&qt_adopted_thread_watcher_mutex); 231 qt_adopted_thread_handles.remove(handleIndex); 232 qt_adopted_qthreads.remove(qthreadIndex); 233 } 234 } 235 } 236 237 #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) 238 239 #ifndef Q_OS_WIN64 240 # define ULONG_PTR DWORD 241 #endif 242 243 typedef struct tagTHREADNAME_INFO 244 { 245 DWORD dwType; // must be 0x1000 246 LPCSTR szName; // pointer to name (in user addr space) 247 HANDLE dwThreadID; // thread ID (-1=caller thread) 248 DWORD dwFlags; // reserved for future use, must be zero 249 } THREADNAME_INFO; 250 251 void qt_set_thread_name(HANDLE threadId, LPCSTR threadName) 252 { 253 THREADNAME_INFO info; 254 info.dwType = 0x1000; 255 info.szName = threadName; 256 info.dwThreadID = threadId; 257 info.dwFlags = 0; 258 259 __try 260 { 261 RaiseException(0x406D1388, 0, sizeof(info)/sizeof(DWORD), (const ULONG_PTR*)&info); 262 } 263 __except (EXCEPTION_CONTINUE_EXECUTION) 264 { 265 } 266 } 267 #endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINCE 212 } 213 } 268 214 269 215 /************************************************************************** … … 275 221 void QThreadPrivate::createEventDispatcher(QThreadData *data) 276 222 { 277 data->eventDispatcher = new QEventDispatcher Win32;223 data->eventDispatcher = new QEventDispatcher; 278 224 data->eventDispatcher->startingUp(); 279 225 } … … 281 227 #ifndef QT_NO_THREAD 282 228 283 unsigned int __stdcall QThreadPrivate::start(void *arg) 229 // static 230 void QThreadPrivate::start(void *arg) 284 231 { 285 232 QThread *thr = reinterpret_cast<QThread *>(arg); … … 287 234 288 235 qt_create_tls(); 289 TlsSetValue(qt_current_thread_data_tls_index, data);236 ; 290 237 291 238 QThread::setTerminationEnabled(false); … … 296 243 createEventDispatcher(data); 297 244 298 #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)299 // sets the name of the current thread.300 QByteArray objectName = thr->objectName().toLocal8Bit();301 qt_set_thread_name((HANDLE)-1,302 objectName.isEmpty() ?303 thr->metaObject()->className() : objectName.constData());304 #endif305 306 245 emit thr->started(); 307 246 QThread::setTerminationEnabled(true); … … 309 248 310 249 finish(arg); 311 return 0; 312 } 313 250 } 251 252 // static 314 253 void QThreadPrivate::finish(void *arg, bool lockAnyway) 315 254 { … … 336 275 QThreadStorageData::finish(reinterpret_cast<void **>(&d->data->tls)); 337 276 338 if (!d->waiters) { 339 CloseHandle(d->handle); 340 d->handle = 0; 341 } 342 343 d->id = 0; 277 d->tid = 0; 344 278 345 279 if (lockAnyway) … … 353 287 Qt::HANDLE QThread::currentThreadId() 354 288 { 355 return (Qt::HANDLE)GetCurrentThreadId(); 289 PTIB ptib; 290 DosGetInfoBlocks(&ptib, NULL); 291 return (Qt::HANDLE)ptib->tib_ptib2->tib2_ultid; 356 292 } 357 293 358 294 int QThread::idealThreadCount() 359 295 { 360 SYSTEM_INFO sysinfo; 361 GetSystemInfo(&sysinfo); 362 return sysinfo.dwNumberOfProcessors; 296 ULONG cpuCnt = 1; 297 APIRET rc = DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, 298 &cpuCnt, sizeof(cpuCnt)); 299 if (rc != NO_ERROR || cpuCnt == 0) 300 cpuCnt = 1; 301 return (int) cpuCnt; 363 302 } 364 303 365 304 void QThread::yieldCurrentThread() 366 305 { 367 #ifndef Q_OS_WINCE 368 if (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) 369 SwitchToThread(); 370 else 371 #endif 372 ::Sleep(0); 306 DosSleep(0); 373 307 } 374 308 375 309 void QThread::sleep(unsigned long secs) 376 310 { 377 ::Sleep(secs * 1000);311 Sleep(secs * 1000); 378 312 } 379 313 380 314 void QThread::msleep(unsigned long msecs) 381 315 { 382 ::Sleep(msecs);316 Sleep(msecs); 383 317 } 384 318 385 319 void QThread::usleep(unsigned long usecs) 386 320 { 387 ::Sleep((usecs / 1000) + 1); 388 } 389 321 DosSleep((usecs / 1000) + 1); 322 } 390 323 391 324 void QThread::start(Priority priority) … … 401 334 d->terminated = false; 402 335 403 /* 404 NOTE: we create the thread in the suspended state, set the 405 priority and then resume the thread. 406 407 since threads are created with normal priority by default, we 408 could get into a case where a thread (with priority less than 409 NormalPriority) tries to create a new thread (also with priority 410 less than NormalPriority), but the newly created thread preempts 411 its 'parent' and runs at normal priority. 412 */ 413 d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start, 414 this, CREATE_SUSPENDED, &(d->id)); 415 416 if (!d->handle) { 336 int tid = _beginthread(QThreadPrivate::start, NULL, d->stackSize, this); 337 d->tid = tid != -1 ? (TID) tid : 0; 338 339 if (tid == -1) { 417 340 qErrnoWarning(errno, "QThread::start: Failed to create thread"); 418 341 d->running = false; … … 421 344 } 422 345 423 // Since Win 9x will have problems if the priority is idle or time critical 424 // we have to use the closest one instead 425 int prio; 426 d->priority = priority; 427 switch (d->priority) { 428 case IdlePriority: 429 if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { 430 prio = THREAD_PRIORITY_LOWEST; 431 } else { 432 prio = THREAD_PRIORITY_IDLE; 433 } 434 break; 435 436 case LowestPriority: 437 prio = THREAD_PRIORITY_LOWEST; 438 break; 439 440 case LowPriority: 441 prio = THREAD_PRIORITY_BELOW_NORMAL; 442 break; 443 444 case NormalPriority: 445 prio = THREAD_PRIORITY_NORMAL; 446 break; 447 448 case HighPriority: 449 prio = THREAD_PRIORITY_ABOVE_NORMAL; 450 break; 451 452 case HighestPriority: 453 prio = THREAD_PRIORITY_HIGHEST; 454 break; 455 456 case TimeCriticalPriority: 457 if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { 458 prio = THREAD_PRIORITY_HIGHEST; 459 } else { 460 prio = THREAD_PRIORITY_TIME_CRITICAL; 461 } 462 break; 463 464 case InheritPriority: 465 default: 466 prio = GetThreadPriority(GetCurrentThread()); 467 break; 468 } 469 470 if (!SetThreadPriority(d->handle, prio)) { 471 qErrnoWarning("QThread::start: Failed to set thread priority"); 472 } 473 474 if (ResumeThread(d->handle) == (DWORD) -1) { 475 qErrnoWarning("QThread::start: Failed to resume new thread"); 476 } 346 setPriority(priority); 477 347 } 478 348 … … 481 351 Q_D(QThread); 482 352 QMutexLocker locker(&d->mutex); 353 354 355 356 483 357 if (!d->running) 484 358 return; … … 487 361 return; 488 362 } 489 TerminateThread(d->handle, 0);363 ); 490 364 d->terminated = true; 491 365 QThreadPrivate::finish(this, false); … … 497 371 QMutexLocker locker(&d->mutex); 498 372 499 if (d-> id == GetCurrentThreadId()) {373 if (d->urrentThreadId()) { 500 374 qWarning("QThread::wait: Thread tried to wait on itself"); 501 375 return false; … … 504 378 return true; 505 379 506 ++d->waiters;507 380 locker.mutex()->unlock(); 508 381 509 bool ret = false; 510 switch (WaitForSingleObject(d->handle, time)) { 511 case WAIT_OBJECT_0: 512 ret = true; 513 break; 514 case WAIT_FAILED: 515 qErrnoWarning("QThread::wait: Thread wait failure"); 516 break; 517 case WAIT_ABANDONED: 518 case WAIT_TIMEOUT: 519 default: 520 break; 382 bool ret = true; 383 TID tid = d->tid; 384 APIRET rc = NO_ERROR; 385 if (time == ULONG_MAX) { 386 rc = DosWaitThread(&tid, DCWW_WAIT); 387 } else { 388 ULONG sleep; 389 do { 390 // OS/2 doesn't support specifying a maximum time to wait for a 391 // thread to end other than infininty, so we run a loop of small 392 // wait intervals (in ms) 393 enum { THREAD_WAIT_INTERVAL = 1000 }; 394 sleep = time > THREAD_WAIT_INTERVAL ? THREAD_WAIT_INTERVAL : time; 395 DosSleep(sleep); 396 rc = DosWaitThread(&tid, DCWW_NOWAIT); 397 if (rc != ERROR_THREAD_NOT_TERMINATED) 398 break; 399 if (d->finished || !d->running) { 400 rc = 0; 401 break; 402 } 403 time -= sleep; 404 } while (time); 405 } 406 if (rc != NO_ERROR && rc != ERROR_INVALID_THREADID) { 407 if (rc != ERROR_THREAD_NOT_TERMINATED) 408 qWarning("QThread::wait: DosWaitThread returned %lu", rc); 409 ret = false; 521 410 } 522 411 523 412 locker.mutex()->lock(); 524 --d->waiters;525 413 526 414 if (ret && !d->finished) { … … 528 416 d->terminated = true; 529 417 QThreadPrivate::finish(this, false); 530 }531 532 if (d->finished && !d->waiters) {533 CloseHandle(d->handle);534 d->handle = 0;535 418 } 536 419 … … 550 433 QThreadPrivate::finish(thr, false); 551 434 locker.unlock(); // don't leave the mutex locked! 552 _endthread ex(0);435 _endthread); 553 436 } 554 437 } … … 563 446 } 564 447 565 // copied from start() with a few modifications:566 567 // Since Win 9x will have problems if the priority is idle or time critical568 // we have to use the closest one instead569 int prio;570 448 d->priority = priority; 571 switch (d->priority) { 572 case IdlePriority: 573 if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { 574 prio = THREAD_PRIORITY_LOWEST; 575 } else { 576 prio = THREAD_PRIORITY_IDLE; 577 } 578 break; 579 580 case LowestPriority: 581 prio = THREAD_PRIORITY_LOWEST; 582 break; 583 584 case LowPriority: 585 prio = THREAD_PRIORITY_BELOW_NORMAL; 586 break; 587 588 case NormalPriority: 589 prio = THREAD_PRIORITY_NORMAL; 590 break; 591 592 case HighPriority: 593 prio = THREAD_PRIORITY_ABOVE_NORMAL; 594 break; 595 596 case HighestPriority: 597 prio = THREAD_PRIORITY_HIGHEST; 598 break; 599 600 case TimeCriticalPriority: 601 if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) { 602 prio = THREAD_PRIORITY_HIGHEST; 603 } else { 604 prio = THREAD_PRIORITY_TIME_CRITICAL; 605 } 606 break; 607 608 case InheritPriority: 609 default: 610 qWarning("QThread::setPriority: Argument cannot be InheritPriority"); 611 return; 612 } 613 614 if (!SetThreadPriority(d->handle, prio)) { 615 qErrnoWarning("QThread::setPriority: Failed to set thread priority"); 616 } 449 450 ULONG prioClass = 0; 451 LONG prioDelta = 0; 452 switch (priority) { 453 case IdlePriority: 454 prioClass = PRTYC_IDLETIME; 455 prioDelta = PRTYD_MINIMUM; 456 break; 457 458 case LowestPriority: 459 prioClass = PRTYC_IDLETIME; 460 break; 461 462 case LowPriority: 463 prioClass = PRTYC_IDLETIME; 464 prioDelta = PRTYD_MAXIMUM; 465 break; 466 467 case NormalPriority: 468 prioClass = PRTYC_REGULAR; 469 break; 470 471 case HighPriority: 472 prioClass = PRTYC_REGULAR; 473 prioDelta = PRTYD_MAXIMUM; 474 break; 475 476 case HighestPriority: 477 prioClass = PRTYC_TIMECRITICAL; 478 break; 479 480 case TimeCriticalPriority: 481 prioClass = PRTYC_TIMECRITICAL; 482 prioDelta = PRTYD_MAXIMUM; 483 break; 484 485 case InheritPriority: 486 default: 487 PTIB ptib; 488 DosGetInfoBlocks( &ptib, NULL ); 489 prioClass = (ptib->tib_ptib2->tib2_ulpri >> 8) & 0xFF; 490 prioDelta = (ptib->tib_ptib2->tib2_ulpri) & 0xFF; 491 break; 492 } 493 494 APIRET rc = DosSetPriority(PRTYS_THREAD, prioClass, prioDelta, d->tid); 495 if (rc != NO_ERROR) 496 qWarning("QThread::setPriority: DosSetPriority returned %lu", rc); 617 497 } 618 498 619 499 QT_END_NAMESPACE 500 620 501 #endif // QT_NO_THREAD -
trunk/src/corelib/thread/qthread_p.h
r2 r69 62 62 #include "QtCore/qmap.h" 63 63 #include "private/qobject_p.h" 64 65 66 67 64 68 65 69 QT_BEGIN_NAMESPACE … … 172 176 #endif // Q_OS_WIN32 173 177 178 179 180 181 182 183 184 185 174 186 QThreadData *data; 175 187 -
trunk/src/corelib/thread/thread.pri
r2 r69 9 9 thread/qwaitcondition.h \ 10 10 thread/qatomic.h 11 11 12 12 # private headers 13 13 HEADERS += thread/qmutex_p.h \ … … 23 23 thread/qsemaphore.cpp \ 24 24 thread/qthread.cpp \ 25 thread/qthreadstorage.cpp 25 thread/qthreadstorage.cpp 26 26 27 27 unix:SOURCES += thread/qmutex_unix.cpp \ … … 32 32 thread/qthread_win.cpp \ 33 33 thread/qwaitcondition_win.cpp 34 35 36 37
Note:
See TracChangeset
for help on using the changeset viewer.