Boost logo

Threads-Devel :

Subject: Re: [Threads-devel] showstopper bug for pthread backend
From: Gaetano Mendola (mendola_at_[hidden])
Date: 2010-07-20 04:33:10


On 07/19/10 09:00, Anthony Williams wrote:
> On 17/07/10 23:40, Gaetano Mendola wrote:
>> On 08/02/2010 17:49, Anthony Williams wrote:
>> > On 08/02/10 16:02, Paul Pogonyshev wrote:
>> >> Can you please look at bug in tickets 2330 and 3735 (both reference
>> >> Ticket 2330 has a proposed patch, but it doesn't compile when applied
>> >> to Boost 1.42 and I don't understand it enough to try to upgrade.
>> >
>> > The patch is insufficient. I have an idea how to fix it, but have not
>> > yet found the time to implement it. If my fix works it should be in
>> > boost 1.43
>>
>> Was this issue solved in boost 1.43? If it was it's worth to add it in
>> the release note, if it was not that's explain the hungs I'm
>> experiencing in my application.
>
> No, this bug has not been fixed.

That's explains it then, I did cut down my code and the code following is
enough to have an hang:

Regards
Gaetano Mendola

#include <boost/thread.hpp>

struct Thread {
  Thread(boost::condition_variable& aCondition)
    : theCondition(aCondition), theMutex()
  { }

  void operator()() {
    boost::mutex::scoped_lock myGuard(theMutex);
    theCondition.wait(myGuard);
  }

  boost::condition_variable& theCondition;
  boost::mutex theMutex;
};

int main(int argc, char** argv) {

  boost::condition_variable myCondition;

  Thread myT1(myCondition);
  Thread myT2(myCondition);

  boost::thread_group myThreadGroup;

  myThreadGroup.create_thread(boost::ref(myT1));
  myThreadGroup.create_thread(boost::ref(myT2));

  boost::this_thread::sleep(boost::posix_time::milliseconds(1000));

  myThreadGroup.interrupt_all();
  myThreadGroup.join_all();
}


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk