void run () {
			while (!queue.empty()) {
				std::shared_ptr<Runnable*> runnable = queue.wait_and_pop();
				Runnable *executable =*runnable.get();
				std::thread t1(&Runnable::operator(),executable);
				threads.push_back(std::move(t1));
			}
		}
예제 #2
0
파일: listing4.4.c 프로젝트: tsuyopon/cpp
void data_preparation_thread()
{
    while(more_data_to_prepare())
    {
        data_chunk const data=prepare_data();
        data_queue.push(data);
    }
}
예제 #3
0
void send_thread(){
	int i = 0;
	while(i<50){
		std::string s;
		squeue.wait_and_pop(s);
		std::cout<<s<<std::endl;
		i++;
	}
}
예제 #4
0
void write_thread(){
	int i = 0;
	while(i <50 ){
		std::string const data = std::string("xxxxxx");
		squeue.push(data);
		i++;
	}
	
}
예제 #5
0
파일: listing4.4.c 프로젝트: tsuyopon/cpp
void data_processing_thread()
{
    while(true)
    {
        data_chunk data;
        data_queue.wait_and_pop(data);
        process(data);
        if(is_last_chunk(data))
            break;
    }
}
예제 #6
0
//main thread
void RealTimeDataProcessor::AppendRealTimeData(TickWrapper& info){
	//(in)front-------------back(out)
	// if m_strategy == nullptr, that means RealTimeDataProcessor is in data-recording mode
	if (m_strategy){
#ifdef UseKDataToInvoke
		bool triggered = m_strategy->tryInvoke(m_DataSeq, m_KDataVec, m_TickSet60, info);
#else
		bool triggered = m_strategy->tryInvoke(m_DataSeq, info);
#endif
		if (triggered){
			Order ord;
			//for now, only permit order_queue has one item.
			if (order_queue.empty() && m_strategy->generateOrder(ord)){
				order_queue.push(ord);
			}
		}
			
	}
	m_DataSeq.push_front(info);

	//construct 1-minutes k-line intermediate data
	if (m_TickSet60.empty()){
		m_TickSet60.push_back(info);
	}
	else{
		if (CommonUtils::InSameMinute(info.Time(), m_TickSet60.front().Time())){
			m_TickSet60.push_back(info);
		}
		else{ // the comming tick data is in next minutes
			KData k1m(m_TickSet60, 60);
			m_KDataVec.push_back(k1m);

			m_TickSet60.clear();
		}
	}
#ifdef SHOW_PROGRESS
	spdlog::get("console")->info() << "> Data queue size :" << m_DataSeq.size();
#endif
}
		inline void doSomething2() {
			queue.push(&doOper2);
		}
		inline void doSomething() {
			queue.push(&doOper);
					
		}