本文整理汇总了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);
}
示例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;
}
}
}
}