Re: [Boost-bugs] [Boost C++ Libraries] #7668: thread_group::join_all() should check whether its threads are joinable

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7668: thread_group::join_all() should check whether its threads are joinable
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-01-10 21:04:09


#7668: thread_group::join_all() should check whether its threads are joinable
------------------------------------+---------------------------------------
  Reporter: boost.lists@… | Owner: viboes
      Type: Bugs | Status: closed
 Milestone: Boost 1.53.0 | Component: thread
   Version: Boost 1.52.0 | Severity: Problem
Resolution: fixed | Keywords: thread;thread_group
------------------------------------+---------------------------------------

Comment (by viboes):

 Replying to [comment:10 Andrew Molyneux <andrew.molyneux@…>]:
> > No. I thread that finish normally is still joinable. From where are
 you deducing this?
> I thought I'd observed it, but on further investigation the situation is
 a bit more complex. My code is actually using thread::timed_join()
 periodically, to check if the thread is still running. I've distilled it
 down to the following code, which triggers the behaviour that surprised
 me:
> {{{#!C++
> void threadFunction()
> {
> boost::this_thread::sleep(boost::posix_time::millisec(100));
> }
>
> int main(int argc, char* argv[])
> {
> boost::thread theThread(threadFunction);
> // Wait long enough to be fairly certain that the thread has finished
> boost::this_thread::sleep(boost::posix_time::millisec(200));
> if (!theThread.timed_join(boost::posix_time::millisec(0)))
> {
> cout << "Thread still running???" << endl;
> return 1;
> }
> theThread.join();
> }
> }}}
>
> When I run that code, I get an exception on the call to
 theThread.join(), complaining that the thread is not joinable. It seems
 that after theThread.timed_join() succeeds, the thread is no longer
 joinable. Is this the expected behaviour?

 Yes, I confirm.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7668#comment:12>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:11 UTC