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


C++ WorkerThread类代码示例

本文整理汇总了C++中WorkerThread的典型用法代码示例。如果您正苦于以下问题:C++ WorkerThread类的具体用法?C++ WorkerThread怎么用?C++ WorkerThread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WorkerThread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: m_NumLocalJobsActive

// CONSTRUCTOR
//------------------------------------------------------------------------------
JobQueue::JobQueue( uint32_t numWorkerThreads ) :
	m_NumLocalJobsActive( 0 ),
	m_DistributableAvailableJobs( 1024, true ),
	m_DistributableJobsMemoryUsage( 0 ),
	m_DistributedJobsRemote( 1204, true ),
	m_DistributedJobsLocal( 128, true ),
	m_DistributedJobsCancelled( 128, true ),
	m_CompletedJobs( 1024, true ),
	m_CompletedJobsFailed( 1024, true ),
	m_CompletedJobs2( 1024, true ),
	m_CompletedJobsFailed2( 1024, true ),
	m_Workers( numWorkerThreads, false )
{
	WorkerThread::InitTmpDir();

	for ( uint32_t i=0; i<numWorkerThreads; ++i )
	{
		// identify each worker with an id starting from 1
		// (the "main" thread is considered 0)
		uint32_t threadIndex = ( i + 1 );
		WorkerThread * wt = FNEW( WorkerThread( threadIndex ) );
		wt->Init();
		m_Workers.Append( wt );
	}
}
开发者ID:zhangf911,项目名称:fastbuild,代码行数:27,代码来源:JobQueue.cpp

示例2: while

ThreadPool::~ThreadPool( )
{
    // --------------------------------------------------------------
    // Request Termination of all worker threads.
    // --------------------------------------------------------------

    m_mList.lock();
    WorkerThreadList list = m_lstThreads;
    m_mList.unlock();

    WorkerThreadList::iterator it = list.begin(); 
    for (; it != list.end(); ++it)
    {
        if (*it != NULL) 
            (*it)->RequestTerminate();
    }

    while (!list.empty())
    {
        WorkerThread *pThread = list.front();
        list.pop_front();
        if (pThread != NULL) 
        {
            pThread->wait();
            delete pThread;
        }
    }
}
开发者ID:txase,项目名称:mythtv,代码行数:28,代码来源:threadpool.cpp

示例3: WorkerThread

void Controller::startWorkInAThread()
{
    WorkerThread *workerThread = new WorkerThread(this);
    connect(workerThread, &WorkerThread::resultReady, this, &Controller::handleResults);
    connect(workerThread, &WorkerThread::finished, workerThread, &QObject::deleteLater);
    workerThread->start();
}
开发者ID:DankOSh,项目名称:test_repository,代码行数:7,代码来源:main.cpp

示例4: l

/*!
 * \brief WorkerThreadPool::findResponsiveThread
 * \return
 */
WorkerThread *WorkerThreadPool::findResponsiveThread()
{
    QMutexLocker l(&threadListMutex);

    if(idleThreads.size()) {
        WorkerThread* wt = idleThreads.takeFirst();
        qDebug()<<"[Main] Using Thread "<<wt->threadId()<<" from idle List";
        return wt;
    } else {
        qDebug()<<"[Main] No Idle Threads trying to find a responsive one";

        int myThread = -1;
        for(int i = 0; i < threads.size(); i++) {
            WorkerRunnable::Load load = threads.at(i)->workLoad();
            if(load == WorkerRunnable::Low) {
                myThread = i;
                break;
            } else if(load == WorkerRunnable::Medium && myThread == -1) {
                myThread = i;
                continue;
            }
        }

        if(myThread >= 0) {
            //move the thread to the back, so it will be picked later the next time
            WorkerThread* t = threads.takeAt(myThread);
            threads.append(t);

            return t;
        }

        //we did not find a thread , enqueue it
    }
    return 0;
}
开发者ID:ConfusedReality,项目名称:pkg_webserver_tufao,代码行数:39,代码来源:workerthreadpool.cpp

示例5: run_normal

/** \brief The normal thread run function.
 *
 * The function to be started by normal workers.
 */
static void run_normal()
{
  boost::mutex::scoped_lock scope(mut);
  boost::thread::id tid = boost::this_thread::get_id();
  WorkerThread* thr = (*threads.find(tid)).second.get();

  while(!quitting)
  {
    if(inner_run_important(scope))
    {
      continue;
    }
    if(inner_run_normal(scope))
    {
      continue;
    }
    wake_normal();
    workers_active.remove(thr);
    workers_sleeping.addLast(thr);
    thr->suspend(scope);
  }

  // Remove from active workers before exiting.
  workers_active.remove(thr);
}
开发者ID:dtbinh,项目名称:faemiyah-demoscene_2010-08_gamedev_orbital_bombardment,代码行数:29,代码来源:dispatch.cpp

示例6: main

int main(int argc, char **args)
{
	WorkerThread wt;
	wt.start();
	wt.wait();
	return 0;
}
开发者ID:chuck211991,项目名称:CornellCup2012,代码行数:7,代码来源:main.cpp

示例7: ThreadMain

unsigned WINAPI WorkerThread::ThreadMain(LPVOID thread){

	WorkerThread* workerThread = (WorkerThread*)thread;
	workerThread->run();
	return 0;

}
开发者ID:junbeomlee,项目名称:TAGTAG,代码行数:7,代码来源:WorkerThread.cpp

示例8: fprintf

/**
 * Called by the monitor thread to harvest idle threads.
 */
void 
ThreadPool::harvestSpareWorkers() {

	PoolObject *po;
	int toFree = 0;

	cond.lock();
	if (stopThePool) {
		cond.unlock();
		return;
	}
	if ((currentThreadCount - currentThreadsBusy) > maxSpareThreads) {
		toFree = currentThreadCount -
			currentThreadsBusy -
			maxSpareThreads;

		if (debug) 
			fprintf(stdout, "ThreadPool.harvestSpareWorkers: Freeing %d threads because they are idle\n",
				toFree);
		for (int i = 0 ; i < toFree ; i++) {
			po = (PoolObject *) idleThreads.pop();
			WorkerThread *c = po->getThread();
			c->terminate();
			currentThreadCount --;
		}
		if (debug)
			fprintf(stdout, "ThreadPool.harvestSpareWorkers: Current Thread Count = %d\n",
				currentThreadCount);
	}
	cond.unlock();
}
开发者ID:followheart,项目名称:try-catch-finally,代码行数:34,代码来源:threadpool.cpp

示例9: tDebug

QDebug tDebug()
{
    WorkerThread* t = qobject_cast<WorkerThread*>(QThread::currentThread());
    if(t)
        return qDebug()<<"["<<t->threadId()<<"]";

    return qDebug();
}
开发者ID:ConfusedReality,项目名称:pkg_webserver_tufao,代码行数:8,代码来源:threadedhttpserver.cpp

示例10: JobCleanup

// Called by a worker thread on return from a job.
void WorkerThread::JobCleanup(void *param)
{
    WorkerThread *worker = (WorkerThread *)param;

    (void) pthread_mutex_lock(&(worker->m_worker_mutex));
    if (worker->m_worker_flags & WORKER_WAIT)
        worker->NotifyWaiters();
}
开发者ID:ballacky13,项目名称:toast,代码行数:9,代码来源:workerthread.cpp

示例11: L_FUNC

void Task::startWorkerThread(const QString &id)
{
  L_FUNC(QString("id='%1'").arg(id));

  WorkerThread *workerThread = new WorkerThread(id, this);
  connect(workerThread, SIGNAL(resultReady(const QString&)), this, SLOT(slotResultReady(const QString&)));
  connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
  workerThread->start();
}
开发者ID:darongE,项目名称:SimpleQtLogger,代码行数:9,代码来源:task.cpp

示例12: wakeUpOneThread

void TaskScheduler::wakeUpOneThread()
{
	WorkerThread* thread = mIdleThreads.pop();
	if(thread)
	{
		SCHEDULER_DEBUG("wakeUpOneThread -- thread #" << thread->getThreadId() << " -- #" << thread->getDoWorkEvent()->getHandle());
		thread->getDoWorkEvent()->fire();
	}
}
开发者ID:maca89,项目名称:Beer,代码行数:9,代码来源:TaskScheduler.cpp

示例13: WorkerThread

void *Thread_Func(void *arg)
{
    WorkerThread *worker = new WorkerThread((RequestQueue *)arg);
    signal(SIGTERM, cleanExit);
    signal(SIGINT, cleanExit);
    signal(SIGPIPE, SIG_IGN);
    worker->mainloop();
    
    pthread_exit(NULL);
}
开发者ID:zx5337,项目名称:proxy,代码行数:10,代码来源:proxy.cpp

示例14: WorkerThread

void MainWindow::on_learnDicOkBtn_clicked()
{
	ui->learnDicOkBtn->setEnabled(false);
	ui->saveCfBtn->setEnabled(false);
	WorkerThread *workerThread = new WorkerThread();
	connect(workerThread, SIGNAL(resultReady()), this, SLOT(updateSisrButtons()));
	connect(workerThread, SIGNAL(exceptionOccurs()), this, SLOT(sisrExceptionOccurs()));

	workerThread->start();
}
开发者ID:HastyJ,项目名称:JsImgProc,代码行数:10,代码来源:mainwindow.cpp

示例15:

// MainWrapper
//------------------------------------------------------------------------------
/*static*/ uint32_t WorkerThread::ThreadWrapperFunc( void * param )
{
	WorkerThread * wt = reinterpret_cast< WorkerThread * >( param );
	s_WorkerThreadThreadIndex = wt->m_ThreadIndex;

	CreateThreadLocalTmpDir();

	wt->Main();
	return 0;
}
开发者ID:zhangf911,项目名称:fastbuild,代码行数:12,代码来源:WorkerThread.cpp


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