home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,463 of 33,346   
   Chris M. Thomasson to Ulrich Eckhardt   
   Re: Weird problem with mutex and lock er   
   13 Sep 11 10:53:07   
   
   From: cristom@charter.net   
      
   "Ulrich Eckhardt"  wrote in message   
   news:f6p0k8-08d.ln1@satorlaser.homedns.org...   
   [...]   
   > Agents Marlow wrote:   
   >>I am getting a nasty error condition from a mutex where it calls   
   >> If my suspicion is right then I don't think it would be right to   
   >> correct this error by changing the concurrent queue to use a recursive   
   >> mutex. What do people think?   
   >   
   > Is the mutex locked recursively and is this intended?   
      
   AFAICT, the recursive locking of the mutex is most definitely "intended";   
   how else does one explain the following function's:   
   ____________________________________________________________   
       bool empty() const   
       {   
           boost::mutex::scoped_lock lock(the_mutex);   
           return the_queue.empty();   
       }   
      
       bool try_pop(Data& popped_value)   
       {   
           boost::mutex::scoped_lock lock(the_mutex);   
           if(the_queue.empty())   
           {   
               return false;   
           }   
      
           popped_value=the_queue.front();   
           the_queue.pop();   
           return true;   
       }   
   ____________________________________________________________   
      
      
   AFAICT, `try_pop()' does lock the mutex twice...    ;^o   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca