static void onAndroidUiThread(JNIEnv *, jclass, jlong thiz) { QRunnable *runnable = reinterpret_cast<QRunnable *>(thiz); if (runnable == 0) return; runnable->run(); if (runnable->autoDelete()) delete runnable; }
void AVDemuxThread::processNextSeekTask() { if (seek_tasks.isEmpty()) return; QRunnable *task = seek_tasks.take(); if (!task) return; task->run(); if (task->autoDelete()) delete task; }
void AVDemuxThread::processNextPauseTask() { if (pause_tasks.isEmpty()) return; QRunnable *task = pause_tasks.dequeue(); if (!task) return; task->run(); if (task->autoDelete()) delete task; }
bool AVThread::processNextTask() { DPTR_D(AVThread); if (d.tasks.isEmpty()) return true; QRunnable *task = d.tasks.takeFirst(); task->run(); if (task->autoDelete()) { delete task; } return true; }
void ThreadPool::Worker::flushQueue() { QMutexLocker lock(&m_queueMutex); while(!m_queue.isEmpty()) { QRunnable* runnable = m_queue.takeFirst(); lock.unlock(); runnable->run(); if(runnable->autoDelete()) { delete runnable; } lock.relock(); } }
/* \internal */ void QThreadPoolThread::run() { QMutexLocker locker(&manager->mutex); for(;;) { QRunnable *r = runnable; runnable = 0; do { if (r) { const bool autoDelete = r->autoDelete(); // run the task locker.unlock(); #ifndef QT_NO_EXCEPTIONS try { #endif r->run(); #ifndef QT_NO_EXCEPTIONS } catch (...) { qWarning("Qt Concurrent has caught an exception thrown from a worker thread.\n" "This is not supported, exceptions thrown in worker threads must be\n" "caught before control returns to Qt Concurrent."); registerTheadInactive(); throw; } #endif locker.relock(); if (autoDelete && !--r->ref) delete r; } // if too many threads are active, expire this thread if (manager->tooManyThreadsActive()) break; r = !manager->queue.isEmpty() ? manager->queue.takeFirst().first : 0; } while (r != 0); if (manager->isExiting) { registerTheadInactive(); break; } // if too many threads are active, expire this thread bool expired = manager->tooManyThreadsActive(); if (!expired) { ++manager->waitingThreads; registerTheadInactive(); // wait for work, exiting after the expiry timeout is reached expired = !manager->runnableReady.wait(locker.mutex(), manager->expiryTimeout); ++manager->activeThreads; if (expired) --manager->waitingThreads; } if (expired) { manager->expiredThreads.enqueue(this); registerTheadInactive(); break; } } }
static PyObject *meth_QRunnable_run(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; PyObject *sipOrigSelf = sipSelf; { QRunnable *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QRunnable, &sipCpp)) { if (!sipOrigSelf) { sipAbstractMethod(sipName_QRunnable, sipName_run); return NULL; } Py_BEGIN_ALLOW_THREADS sipCpp->run(); Py_END_ALLOW_THREADS Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QRunnable, sipName_run, doc_QRunnable_run); return NULL; }