Пример #1
0
 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) );
 }
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);
	}
}
Пример #3
0
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;
}
Пример #4
0
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;
}
Пример #5
0
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;
}
Пример #6
0
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();
}
Пример #7
0
	explicit mediator()
	{
		for (size_t i = 0; i < thread_count_; ++i)
			tg.add_thread( new boost::thread( &mediator::do_some_job_, this ) );
	}
Пример #8
0
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);
}