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