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


C++ TaskQueue::push_back方法代码示例

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


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

示例1: move_task_to_ready_queue

int Worker::move_task_to_ready_queue(TaskQueue_Item **qi) {
	//pthread_mutex_lock(&w_lock);
	pthread_mutex_lock(&lock);
	rqueue.push_back(*qi);
	//wqueue.erase(*qi);
	pthread_mutex_unlock(&lock);
	//pthread_mutex_unlock(&w_lock);
}
开发者ID:kwangiit,项目名称:matrix,代码行数:8,代码来源:matrix_server.cpp

示例2: HB_insertQ_new

// Insert tasks into queue without repeated fields
//int32_t Worker::HB_insertQ_new(NoVoHT *map, Package &package) {
void* HB_insertQ_new(void* args) {

	package_thread_args targs = *((package_thread_args*) args);
	queue<string*> *source = targs.source;
	TaskQueue *dest = targs.dest;
	pthread_mutex_t *slock = targs.slock;
	pthread_mutex_t *dlock = targs.dlock;
	Worker *worker = targs.worker;

	string *st;
	Package package;

	while (ON) {
		while (source->size() > 0) {
			pthread_mutex_lock(slock);
			if (source->size() > 0) {
				try {
					st = source->front();
					source->pop(); //cout << "recd something" << endl;
				} catch (exception& e) {
					cout << "void* HB_insertQ_new: " << e.what() << endl;
					exit(1);
				}
			} else {
				pthread_mutex_unlock(slock);
				continue;
			}
			pthread_mutex_unlock(slock);
			package.ParseFromString(*st);
			delete st;

			TaskQueue_Item *qi;

			uint32_t task_recd_count = 0;
			string alltasks(package.realfullpath());
			int num_vector_count, per_vector_count;
			vector<vector<string> > tokenize_string = tokenize(alltasks, '\"',
					'\'', num_vector_count, per_vector_count);
			//cout << "num_vector_count = " << num_vector_count << " per_vector_count = " << per_vector_count << endl;
			task_recd_count = num_vector_count;
			for (int i = 0; i < num_vector_count; i++) {
				qi = new TaskQueue_Item();
				try {
					qi->task_id = tokenize_string.at(i).at(0); //cout << "insertq: qi->task_id = " << qi->task_id << endl;
				} catch (exception& e) {
					cout
							<< "void* HB_insertQ_new: (tokenize_string.at(i).at(0)) "
							<< " " << e.what() << endl;
					exit(1);
				}
				/*stringstream num_moves_ss;
				 try {
				 num_moves_ss << tokenize_string.at(i).at(1);
				 }
				 catch (exception& e) {
				 cout << "void* HB_insertQ_new: (tokenize_string.at(i).at(0)) " << " " << e.what() << endl;
				 exit(1);
				 }
				 num_moves_ss >> qi->num_moves;*/

				if (LOGGING) {
					task_fp << " taskid = " << qi->task_id;
					//task_fp << " num moves = " << qi->num_moves;
				}

				pthread_mutex_lock(dlock);
				try {
					dest->push_back(qi);
				} catch (std::bad_alloc& exc) {
					cout
							<< "HB_InsertQ_new: cannot allocate memory while adding element to ready queue"
							<< endl;
					pthread_exit(NULL);
				}
				pthread_mutex_unlock(dlock);
			}
			if (LOGGING) {
				log_fp << "Num tasks received = " << task_recd_count
						<< " Queue length = " << dest->size() << endl;
			}
		}
	}
}
开发者ID:kwangiit,项目名称:matrix,代码行数:85,代码来源:matrix_server.cpp


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