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: 2012-12-07 19:45:34


#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:6 mendola@…]:
> The fix doesn't solve the problem indeed the thread can detach itself so
 between the call joinable() and join() the precondition would not be valid
 anymore.


 From my point of view a thread in a thread_group is owned by the thread
 group. Any direct operation on a thread belonging to the thread group
 falls in undefined behavior. From the documentation


 {{{
 Member function create_thread()

 template<typename F>
 thread* create_thread(F threadfunc);

 Effects:

     Create a new boost::thread object as-if by new thread(threadfunc) and
 add it to the group.
 Postcondition:

     this->size() is increased by one, the new thread is running.
 Returns:

     A pointer to the new boost::thread object.


 Member function add_thread()

 void add_thread(thread* thrd);

 Precondition:

     The expression delete thrd is well-formed and will not result in
 undefined behaviour.
 Effects:

     Take ownership of the boost::thread object pointed to by thrd and add
 it to the group.
 Postcondition:

     this->size() is increased by one.


 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7668#comment:7>
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