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


C++ thread_group::add_thread方法代码示例

本文整理汇总了C++中boost::thread_group::add_thread方法的典型用法代码示例。如果您正苦于以下问题:C++ thread_group::add_thread方法的具体用法?C++ thread_group::add_thread怎么用?C++ thread_group::add_thread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::thread_group的用法示例。


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

示例1:

 parallel_test()
 {
     group_.add_thread( new boost::thread(&parallel_test::insert_sleep_removes_aspect1, this) );
     group_.add_thread( new boost::thread(&parallel_test::insert_sleep_removes_aspect2, this) );
     group_.add_thread( new boost::thread(&parallel_test::find_and_access, this) );
     group_.add_thread( new boost::thread(&parallel_test::insert_sleep_aspect1, this) );
     group_.add_thread( new boost::thread(&parallel_test::use_sleep_remove_aspect1, this) );
 }
开发者ID:caomw,项目名称:Boost.Application,代码行数:8,代码来源:aspect_map_test.cpp

示例2: thread

void thread(FFMPEGData &vidData)
{
	int counter = 0;
	// changed this to use member function.
	if (vidData.startFFMPEG() < 0)
	{
		printf("should not get here.\n");
	}
	plays.add_thread(new boost::thread(play, vidData));
	while (true)
	{
		printf("\t\tthread count = %d\n", counter);
		// Read frames from the stream.
		if (av_read_frame(vidData.pFormatCtx, &vidData.pack[counter]) != AVERROR(EAGAIN))
		{
			if (counter < packetNum)
			{
				counter++;
			}
			else
			{
				counter = 0;
			}
		}

		//Sleep(25);
	}
}
开发者ID:lorengaravaglia,项目名称:thesis-scripts,代码行数:28,代码来源:Video+Player.cpp

示例3: ctp_trade_init

int ctp_trade_init(string tradedir)
{
		g_trader=new Trader(g_username,g_password,g_brokerid,g_trade_addr);
		g_ctp_trader=new CtpTrader(g_trader,g_dmgr,g_instmgr,tradedir);
		g_ctp_trader->init();
		g_trade_tg.add_thread(new boost::thread(trader_loop,g_ctp_trader,0));
		g_ctp_trader->start();
		return 0;
}
开发者ID:peidright,项目名称:plt_dev,代码行数:9,代码来源:main.cpp

示例4: ctp_quote_init

int ctp_quote_init(string quotedir)
{
		int ret=0;
		int i,count;
		char **ppinstn;

		g_quoter=new Quoter(g_username,g_password,g_brokerid,g_quote_addr);
		g_ctp_quoter=new CtpQuoter(g_quoter,g_dmgr,g_instmgr,quotedir);
		g_mdservice=new mdservice();
		g_ctp_quoter->init(g_mdservice);
		/*
		 *todo regmd all
		 * */

		/*-1=get old, 1=get new, 0=get all*/
		g_ctp_quoter->pinstmgr->get_inst_list(&ppinstn,&count, 0);
        LOG_DEBUG<<"get_inst_list count:"<<count<<std::endl;
		for(i=0;i<count;i++) {
			//regmd
			//1.to fix this code, rebuild. 2. if new inst, we need regmd...
			g_ctp_quoter->mds->regmd(ppinstn[i], g_ctp_quoter->pinstmgr->instmap[ppinstn[i]]);

			//reg one minute k
			ret=g_ctp_quoter->mds->regmd_period(ppinstn[i],MINUTE,1);
			assert(ret==0);
			g_ctp_quoter->mds->loadmd_period(ppinstn[i], 1, g_dmgr);
		}
		LOG_DEBUG<<"ctp_quote_init get all inst and reg all the md"<<std::endl;

		for (i=0;i< CTP_WORK_THREAD_NUM;i++){
			g_quote_tg.add_thread(new boost::thread(DepthMarketProcess,g_ctp_quoter,i));
		}
		g_quote_tg.add_thread(new boost::thread(quote_loop,g_ctp_quoter));
		g_ctp_quoter->start();
		g_io_tg.add_thread(new boost::thread(quote_io_work));
		return 0;
}
开发者ID:peidright,项目名称:plt_dev,代码行数:37,代码来源:main.cpp

示例5: run_test

void client::run_test()
{
	unsigned optimal_threads_count = boost::thread::hardware_concurrency();

	if (optimal_threads_count == 0)
		optimal_threads_count = 1;

	ostream_ << "Create " << optimal_threads_count << " threads for client" << std::endl;

	for (unsigned i = 0; i < optimal_threads_count; ++i)
		threads_.add_thread(new boost::thread([this, i] () { thread_func(i); }));

	threads_.join_all();
	ostream_ << "All client's threads done" << std::endl;
}
开发者ID:sfff,项目名称:example,代码行数:15,代码来源:example.cpp

示例6: main

int main()
{
  {
    boost::thread_group threads;
    for (int i = 0; i < 3; ++i)
        threads.create_thread(&increment_count);
    threads.join_all();
  }
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
  {
    boost::thread_group threads;
    for (int i = 0; i < 3; ++i)
        threads.create_thread(&increment_count);
    threads.interrupt_all();
    threads.join_all();
  }
#endif
  {
    boost::thread_group threads;
    boost::thread* th = new boost::thread(&increment_count);
    threads.add_thread(th);
    BOOST_TEST(! threads.is_this_thread_in());
    threads.join_all();
  }
  {
    boost::thread_group threads;
    boost::thread* th = new boost::thread(&increment_count);
    threads.add_thread(th);
    BOOST_TEST(threads.is_thread_in(th));
    threads.remove_thread(th);
    BOOST_TEST(! threads.is_thread_in(th));
    th->join();
  }
  {
    {
      boost::unique_lock<boost::mutex> lock(mutex);
      boost::thread* th2 = new boost::thread(&increment_count_2);
      threads2.add_thread(th2);
    }
    threads2.join_all();
  }
  return boost::report_errors();
}
开发者ID:MisterTea,项目名称:MAMEHub,代码行数:43,代码来源:thread_group.cpp

示例7: mediator

	explicit mediator()
	{
		for (size_t i = 0; i < thread_count_; ++i)
			tg.add_thread( new boost::thread( &mediator::do_some_job_, this ) );
	}
开发者ID:Gedeon-by,项目名称:cpp_craft_0314,代码行数:5,代码来源:sys_proc_example.cpp

示例8: exec_finder

void exec_finder(boost::thread_group &worker_group, boost::ptr_vector<FireballFinder> &fb_finders, VideoPartition *prt, CmdOptions *opt) {
    FireballFinder *ff = new FireballFinder(*prt, *opt);
    ff->execute();
    worker_group.add_thread(ff->get_worker());
    fb_finders.push_back(ff);
}
开发者ID:mszubart,项目名称:Find-FireBalls,代码行数:6,代码来源:VideoPartitioner.cpp


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