void QQmlThread::internalCallMethodInThread(Message *message) { Q_ASSERT(!isThisThread()); d->lock(); Q_ASSERT(d->m_mainThreadWaiting == false); bool wasEmpty = d->threadList.isEmpty(); d->threadList.append(message); if (wasEmpty && d->m_threadProcessing == false) d->triggerThreadEvent(); d->m_mainThreadWaiting = true; do { if (d->mainSync) { QQmlThread::Message *message = d->mainSync; unlock(); message->call(this); delete message; lock(); d->mainSync = 0; wakeOne(); } else { d->wait(); } } while (d->mainSync || !d->threadList.isEmpty()); d->m_mainThreadWaiting = false; d->unlock(); }
void QQmlThreadPrivate::threadEvent() { lock(); if (m_shutdown) { quit(); wakeOne(); unlock(); q->shutdownThread(); } else { m_threadProcessing = true; while (!threadList.isEmpty()) { QQmlThread::Message *message = threadList.first(); unlock(); message->call(q); lock(); delete threadList.takeFirst(); } wakeOne(); m_threadProcessing = false; unlock(); } }
void QQmlThread::waitForNextMessage() { Q_ASSERT(!isThisThread()); d->lock(); Q_ASSERT(d->m_mainThreadWaiting == false); d->m_mainThreadWaiting = true; if (d->mainSync || !d->threadList.isEmpty()) { if (d->mainSync) { QQmlThread::Message *message = d->mainSync; unlock(); message->call(this); delete message; lock(); d->mainSync = 0; wakeOne(); } else { d->wait(); } } d->m_mainThreadWaiting = false; d->unlock(); }
void QQmlThreadPrivate::mainEvent() { lock(); m_mainProcessing = true; while (!mainList.isEmpty() || mainSync) { bool isSync = mainSync != 0; QQmlThread::Message *message = isSync?mainSync:mainList.takeFirst(); unlock(); message->call(q); delete message; lock(); if (isSync) { mainSync = 0; wakeOne(); } } m_mainProcessing = false; unlock(); }
void QQmlThreadPrivate::threadEvent() { lock(); for (;;) { if (m_shutdown) { quit(); wakeOne(); unlock(); return; } else if (!threadList.isEmpty()) { m_threadProcessing = true; QQmlThread::Message *message = threadList.first(); unlock(); message->call(q); lock(); delete threadList.takeFirst(); } else { wakeOne(); m_threadProcessing = false; unlock(); return; } } }