当前位置: 首页>>代码示例>>C++>>正文


C++ QRunnable::autoDelete方法代码示例

本文整理汇总了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);
}
开发者ID:151706061,项目名称:QtAV,代码行数:9,代码来源:AVDemuxThread.cpp

示例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;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:10,代码来源:qjnihelpers.cpp

示例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;
}
开发者ID:151706061,项目名称:QtAV,代码行数:11,代码来源:AVDemuxThread.cpp

示例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;
}
开发者ID:bianshifeng,项目名称:QtAV,代码行数:11,代码来源:AVDemuxThread.cpp

示例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;
}
开发者ID:LinDing,项目名称:QtAV,代码行数:12,代码来源:AVThread.cpp

示例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();
		}
	}
开发者ID:pivaldi,项目名称:fastcgiqt,代码行数:15,代码来源:ThreadPool_Worker.cpp

示例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;
        }
    }
}
开发者ID:xkfz007,项目名称:vlc,代码行数:67,代码来源:qthreadpool.cpp


注:本文中的QRunnable::autoDelete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。