• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ WorkerThread类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: InitiateReconnect

static void InitiateReconnect()
{
    WorkerThread *thr = WorkerThread::This();
    if (thr)
    {
        // Defer sending the completion of exposure message until after
        // the camera re-connecttion attempt
        thr->SetSkipExposeComplete();
    }
    pFrame->TryReconnect();
}
开发者ID:AndresPozo,项目名称:phd2,代码行数:11,代码来源:camera.cpp


示例17: return

// worker thread is a thread that wait work in the work queue
WorkerThread * WorkerThread::Create(pthread_attr_t *attr)
{
    WorkerThread *worker;
    if((worker = new (std::nothrow)WorkerThread(attr)) == NULL)
    {
        errno = ENOMEM;
        return (NULL);
    }
    worker->CreateWorker();
    return (worker);
}
开发者ID:ballacky13,项目名称:toast,代码行数:12,代码来源:workerthread.cpp


示例18: ConnEventCB

	void WorkerThread::ConnEventCB(bufferevent *bev, short int events,
	        void * ctx)
	{
		ConnItem * pitem = static_cast<ConnItem *>(ctx);
		WorkerThread * pwt = static_cast<WorkerThread*>(pitem->pthis);
		if (pitem->log_fd != -1)	//连接意外关闭,关闭写日志文件描述符
			close(pitem->log_fd);
		pwt->DeleteConnItem(*pitem);	//从线程队列中删除连接对象
		bufferevent_free(bev);
		msghandler->sessionClosed(pitem);
	}
开发者ID:captainl1993,项目名称:Mnet,代码行数:11,代码来源:WorkerThread.cpp


示例19: allThreadsIdle

bool TaskScheduler::allThreadsIdle()
{
	// ugly, TODO
	uint16 idleCount = 0;
	for(uint16 i = 0; i < mThreadsCount; i++)
	{
		WorkerThread* thread = mAllThreads[i];
		if(thread->isIdle()) idleCount++;
	}

	return idleCount == mThreadsCount;
}
开发者ID:maca89,项目名称:Beer,代码行数:12,代码来源:TaskScheduler.cpp


示例20: TEST

TEST(WorkerThread, FutureVoid) {
  int callbacks = 0;
  WorkerThread<void(int)> worker;
  future<void> f = worker.QueueWork(
      [&](int v) {
        ++callbacks;
        ASSERT_EQ(v, 3);
      },
      3);
  f.get();
  ASSERT_EQ(callbacks, 1);
}
开发者ID:AustinShalit,项目名称:allwpilib,代码行数:12,代码来源:WorkerThreadTest.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WorkingSet类代码示例发布时间:2022-05-31
下一篇:
C++ WorkerScriptController类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap