本文整理汇总了C++中QRunnable::autoDelete方法的典型用法代码示例。如果您正苦于以下问题:C++ QRunnable::autoDelete方法的具体用法?C++ QRunnable::autoDelete怎么用?C++ QRunnable::autoDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRunnable
的用法示例。
在下文中一共展示了QRunnable::autoDelete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newSeekRequest
void AVDemuxThread::newSeekRequest(QRunnable *r)
{
if (seek_tasks.size() >= seek_tasks.capacity()) {
QRunnable *r = seek_tasks.take();
if (r->autoDelete())
delete r;
}
seek_tasks.put(r);
}
示例2: onAndroidUiThread
static void onAndroidUiThread(JNIEnv *, jclass, jlong thiz)
{
QRunnable *runnable = reinterpret_cast<QRunnable *>(thiz);
if (runnable == 0)
return;
runnable->run();
if (runnable->autoDelete())
delete runnable;
}
示例3: processNextSeekTask
void AVDemuxThread::processNextSeekTask()
{
if (seek_tasks.isEmpty())
return;
QRunnable *task = seek_tasks.take();
if (!task)
return;
task->run();
if (task->autoDelete())
delete task;
}
示例4: processNextPauseTask
void AVDemuxThread::processNextPauseTask()
{
if (pause_tasks.isEmpty())
return;
QRunnable *task = pause_tasks.dequeue();
if (!task)
return;
task->run();
if (task->autoDelete())
delete task;
}
示例5: processNextTask
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;
}
示例6: lock
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();
}
}
示例7: run
/* \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;
}
}
}