[Boost-bugs] [Boost C++ Libraries] #7496: [thread] call interrupt() and join() int destructor of a joinable thread

Subject: [Boost-bugs] [Boost C++ Libraries] #7496: [thread] call interrupt() and join() int destructor of a joinable thread
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-10-11 13:34:19


#7496: [thread] call interrupt() and join() int destructor of a joinable thread
------------------------------------------------------+---------------------
 Reporter: Andrzej Krzemienski <akrzemi1@…> | Owner: anthonyw
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.52.0 | Severity: Problem
 Keywords: thread interrupt join destructor |
------------------------------------------------------+---------------------
 boost::thread's destructor calls terminate if joinable, in order to
 conform to C++11 specification. I am not sure if this is the best course
 of action.
 My understanding -- form the C++ Committee papers and informal
 presentations -- is that the reason for introducing a 'terminating
 destructor' was the lack of thread cancellation/interruption
 functionality. Thread interruption is supposed to be the preferred
 behavior for thread's destructor. std::thread does not support
 interruption (for some reasons), but boost::thread does (this is already a
 departure from C++11), so shouldn't the latter prefer to interrupt and
 join a joinable thread in the destructor?


 My preference would be to join (rater than detach) after the interruption.
 If I remember correctly, the argument against joining for std::thread is
 that there would be an unexpected hang upon reaching the end of the scope.
 The argument against detaching for std::thread is that the detached thread
 may be holding references to automatic variables defined in the scope of
 the forking thread that we are now exiting.

 I believe that with thread interruption in place the argument against
 joining is mitigated, while the argument against detaching still holds.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7496>
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:10 UTC