我有这个代码:
void threaded_function(Model_factory &mf, ppa::Node *root)
{
boost::mutex::scoped_lock lock(result_mutex);
typedef vector<boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> >
::iterator traveling;
if(!running_jobs.empty())
{
cout << "size of running " << running_jobs.size() << endl;
boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> tuple_to_check =
running_jobs.front();
running_jobs.pop();
cout << "poping this object from running_jobs" << tuple_to_check << endl;
cout << "new size of running " << running_jobs.size() << endl;
lock.unlock();
ppa::Node *tuplets_father = boost::get<0>(tuple_to_check);
ppa::Node *first_son = boost::get<1>(tuple_to_check);
ppa::Node *second_son = boost::get<2>(tuple_to_check);
bool is_this_done = boost::get<3>(tuple_to_check);
tuplets_father->start_alignment_new(&mf);
lock.lock();
cout << "size of the wait " << wait.size() << endl;
boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> new_tuple
= boost::make_tuple(tuplets_father, first_son, second_son, true);
wait.push_back(new_tuple);
cout << "pushing this object to waiting list" << new_tuple << endl;
不必滚动的空间
cout << "new size of the wait " << wait.size() << endl;
lock.unlock();
lock.lock();
for(traveling i = wait.begin(); i != wait.end(); i++)
{
if(boost::get<3>(*i) == true)
{
cout << "found in here pushing to running jobs " << *i << endl;
boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> tuple = *i;
wait.erase(i);
running_jobs.push(tuple);
}
}
lock.unlock();
}
else
{
boost::this_thread::yield();
}
这是我的一部分输出:
found in here pushing to running jobs (0 0x1dd00000142 0xffffffff00000143 1)
found in here pushing to running jobs (0 0 0 66)
found in here pushing to running jobs (0 0 0x1e000000142 67)
found in here pushing to running jobs (0 0x1e100000142 0xffffffff00000143 1)
found in here pushing to running jobs (0 0 0 66)
found in here pushing to running jobs (0 0 0x1e400000142 67)
found in here pushing to running jobs (0 0x1e500000142 0xffffffff00000143 1)
found in here pushing to running jobs (0 0 0 66)
found in here pushing to running jobs (0 0 0x1e800000142 67)
found in here pushing to running jobs (0 0x1e900000142 0xffffffff00000143 1)
found in here pushing to running jobs (0 0 0 66)
found in here pushing to running jobs (0 0 0x1ec00000142 67)
它将永远消失,我想知道错误在哪里,是否与逻辑有关?很可能是的,但我可以用一些新的眼睛,谢谢。