title: c++ tuples, vector and threads code
body: <p>I have this code:</p>
  
  <pre><code>   void threaded_function(Model_factory &amp;mf, ppa::Node *root)
  {
  
    boost::mutex::scoped_lock lock(result_mutex);
    typedef  vector&lt;boost::tuple&lt;ppa::Node*, ppa::Node*, ppa::Node*, bool&gt; &gt;
    ::iterator traveling;
  
    if(!running_jobs.empty())
    {
        cout &lt;&lt; "size of running " &lt;&lt; running_jobs.size() &lt;&lt; endl;
        boost::tuple&lt;ppa::Node*, ppa::Node*, ppa::Node*, bool&gt; tuple_to_check = 
        running_jobs.front();
        running_jobs.pop();
  
        cout &lt;&lt; "poping this object from running_jobs" &lt;&lt; tuple_to_check &lt;&lt; endl;
        cout &lt;&lt; "new size of running " &lt;&lt; running_jobs.size() &lt;&lt; endl;
  
        lock.unlock();
        ppa::Node *tuplets_father = boost::get&lt;0&gt;(tuple_to_check);
        ppa::Node *first_son = boost::get&lt;1&gt;(tuple_to_check);
        ppa::Node *second_son = boost::get&lt;2&gt;(tuple_to_check);
        bool is_this_done = boost::get&lt;3&gt;(tuple_to_check);
  
        tuplets_father-&gt;start_alignment_new(&amp;mf);
  
        lock.lock();
        cout &lt;&lt; "size of the wait " &lt;&lt; wait.size() &lt;&lt; endl;
  
         boost::tuple&lt;ppa::Node*, ppa::Node*, ppa::Node*, bool&gt; new_tuple
         = boost::make_tuple(tuplets_father, first_son, second_son, true);
         wait.push_back(new_tuple);
         cout &lt;&lt; "pushing this object to waiting list" &lt;&lt; new_tuple &lt;&lt; endl;
  </code></pre>
  
  <p>Space to not have to scroll   </p>
  
  <pre><code>       cout &lt;&lt; "new size of the wait " &lt;&lt; wait.size() &lt;&lt; endl;  
  
  
       lock.unlock();
  
       lock.lock();
  
         for(traveling i = wait.begin(); i != wait.end(); i++)
        {
            if(boost::get&lt;3&gt;(*i) == true)
            {
  
  
                cout &lt;&lt; "found in here pushing to running jobs " &lt;&lt; *i &lt;&lt;  endl;
                boost::tuple&lt;ppa::Node*, ppa::Node*, ppa::Node*, bool&gt;  tuple = *i;
                wait.erase(i);
                running_jobs.push(tuple);
  
  
  
            }
        }
         lock.unlock();
  
    } 
  
    else
    {
  
        boost::this_thread::yield();
  
    } 
  </code></pre>
  
  <p>And this is a piece of my output:</p>
  
  <pre><code> 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)
  </code></pre>
  
  <p>It will go forever, and I wonder where is the mistake, is it with the logic? Most likely yes, but I could use some new pair of eyes, thanks.</p>