| 204 | } |
| 205 | |
| 206 | bool |
| 207 | GenericSchedulerThreadPrivate::waitForThreadsToQuit_internal(bool allowBlockingForMainThread) |
| 208 | { |
| 209 | if ( !_p->isRunning() ) { |
| 210 | return false; |
| 211 | } |
| 212 | |
| 213 | { |
| 214 | QMutexLocker k(&threadStateMutex); |
| 215 | if (threadState == GenericSchedulerThread::eThreadStateStopped) { |
| 216 | return false; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | // This function may NOT be called on the main-thread, because we may deadlock if executeOnMainThread is called OR block the UI. |
| 221 | if ( !allowBlockingForMainThread && ( QThread::currentThread() == qApp->thread() ) ) { |
| 222 | return false; |
| 223 | } |
| 224 | |
| 225 | { |
| 226 | QMutexLocker k(&mustQuitMutex); |
| 227 | while (mustQuit) { |
| 228 | mustQuitCond.wait(&mustQuitMutex); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | // call pthread_join() to ensure the thread has stopped, this should be instantaneous anyway since we ensured we returned from the run() function already |
| 233 | _p->wait(); |
| 234 | |
| 235 | _p->onWaitForThreadToQuit(); |
| 236 | |
| 237 | return true; |
| 238 | } |
| 239 | |
| 240 | void |
| 241 | GenericSchedulerThread::waitForThreadToQuitQueued_main_thread(bool allowRestart) |
no test coverage detected