Ticket #6266: 6266.patch

File 6266.patch, 9.5 KB (added by viboes, 11 years ago)
  • boost/thread/detail/config.hpp

     
    4545#define BOOST_THREAD_SHARED_MUTEX_GENERIC
    4646#endif
    4747
    48 
    4948// Don't provided by default in version 1.
    5049#if defined BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
    5150#define BOOST_THREAD_EXPLICIT_LOCK_CONVERSION explicit
     
    6463#endif
    6564
    6665#if BOOST_THREAD_VERSION==2
     66#define BOOST_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
     67#define BOOST_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
    6768#define BOOST_THREAD_USES_FUTURE
    6869#define BOOST_THREAD_FUTURE_USES_ALLOCATORS
    6970#define BOOST_THREAD_SHARED_MUTEX_PROVIDES_UPWARDS_CONVERSION
  • boost/thread/detail/thread.hpp

     
    208208        thread(const volatile thread&);
    209209#endif
    210210        thread() BOOST_NOEXCEPT;
    211         ~thread();
    212 
     211        ~thread()
     212        {
     213    #if defined BOOST_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
     214          if (joinable()) {
     215            std::terminate();
     216          }
     217    #else
     218            detach();
     219    #endif
     220        }
    213221#ifndef BOOST_NO_RVALUE_REFERENCES
    214222        template <
    215223          class F
     
    239247
    240248        thread& operator=(thread&& other) BOOST_NOEXCEPT
    241249        {
     250#if defined BOOST_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
     251            if (joinable()) std::terminate();
     252#endif
    242253            thread_info=other.thread_info;
    243254            other.thread_info.reset();
    244255            return *this;
     
    354365#if defined BOOST_THREAD_USES_MOVE
    355366        thread& operator=(boost::rv<thread>& x) BOOST_NOEXCEPT
    356367        {
     368#if defined BOOST_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
     369            if (joinable()) std::terminate();
     370#endif
    357371            thread new_thread(boost::move(x));
    358372            swap(new_thread);
    359373            return *this;
     
    361375#else
    362376        thread& operator=(detail::thread_move_t<thread> x) BOOST_NOEXCEPT
    363377        {
     378#if defined BOOST_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
     379            if (joinable()) std::terminate();
     380#endif
    364381            thread new_thread(x);
    365382            swap(new_thread);
    366383            return *this;
  • libs/thread/test/threads/thread/destr/dtor_pass.cpp

     
    1717
    1818// ~thread();
    1919
     20#define BOOST_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
     21
    2022#include <boost/thread/thread.hpp>
    2123#include <new>
    2224#include <cstdlib>
     
    5860
    5961void f1()
    6062{
    61   std::exit(0);
     63  std::exit(boost::report_errors());
    6264}
    6365
    6466int main()
     
    7173#if defined BOOST_THREAD_USES_CHRONO
    7274    boost::this_thread::sleep_for(boost::chrono::milliseconds(250));
    7375#endif
     76    BOOST_TEST(t.joinable());
    7477  }
    75 #if 0
    7678  BOOST_TEST(false);
    77 #endif
    7879  return boost::report_errors();
    7980}
    8081
  • libs/thread/test/threads/thread/assign/move_pass.cpp

     
    1818
    1919// thread& operator=(thread&& t);
    2020
     21#define BOOST_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
     22
    2123#include <boost/thread/thread.hpp>
    2224#include <new>
    2325#include <cstdlib>
     
    6971
    7072void f1()
    7173{
    72   std::exit(0);
     74  std::exit(boost::report_errors());
    7375}
    7476
    7577int main()
     
    8587    BOOST_TEST(t1.get_id() == id);
    8688    BOOST_TEST(t0.get_id() == boost::thread::id());
    8789    t1.join();
    88 #if 0
    89     BOOST_TEST(G::n_alive == 0);
    90 #endif
    9190    BOOST_TEST(G::op_run);
    9291  }
     92  BOOST_TEST(G::n_alive == 0);
    9393  {
    9494    boost::thread t0(G(), 5, 5.5);
    9595    boost::thread::id id = t0.get_id();
    9696    boost::thread t1;
    9797    t0 = boost::move(t1);
    98 #if 0
    9998    BOOST_TEST(false);
    100 #endif
    10199  }
    102100  return boost::report_errors();
    103101}
  • libs/thread/doc/thread_ref.qbk

     
    462462[variablelist
    463463
    464464[[Effects:] [Transfers ownership of the thread managed by `other` (if
    465 any) to `*this`. If there was a thread previously associated with
    466 `*this` then that thread is detached.]]
     465any) to `*this`. Version 1: If there was a thread previously associated with
     466`*this` then that thread is detached, version 2: If the thread is joinable calls to std::terminate.]]
    467467
    468468[[Postconditions:] [`other->get_id()==thread::id()` and `get_id()` returns the value of `other.get_id()` prior to the assignment.]]
    469469
     
    620620
    621621[variablelist
    622622
    623 [[Effects:] [If `*this` has an associated thread of execution, calls __detach__. Destroys `*this`.]]
     623[[Effects:] [Version 1: If `*this` has an associated thread of execution, calls __detach__, Version 2: If the thread is joinable calls to std::terminate. Destroys `*this`.]]
    624624
    625625[[Throws:] [Nothing.]]
    626626
  • libs/thread/doc/configuration.qbk

     
    117117
    118118[endsect]
    119119
     120[section:terminate Call to terminate if joinable]
    120121
     122C++11 has a different semantic for the thread destructor and the move assignment. Instead of detaching the thread, calls to terminate() if the thread was joinable. When `BOOST_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE` and `BOOST_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE` is defined Boost.Thread provides the C++ semantic.
    121123
     124[endsect]
     125
     126
    122127[section:version `BOOST_THREAD_VERSION` Version]
    123128
    124129`BOOST_THREAD_VERSION` defines the Boost.Thread version.
     
    130135* Breaking change `BOOST_THREAD_USES_FUTURE`
    131136* Uniformity `BOOST_THREAD_SHARED_MUTEX_GENERIC`
    132137* Extension `BOOST_THREAD_SHARED_MUTEX_PROVIDES_UPWARDS_CONVERSION`
    133 * Extension `BOOST_THREAD_FUTURE_USES_ALLOCATORS`
     138* Conformity `BOOST_THREAD_FUTURE_USES_ALLOCATORS`
     139* Breaking change BOOST_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
     140* Breaking change BOOST_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
    134141
    135 
    136142[endsect]
    137143
    138144[endsect]
    139  No newline at end of file
  • libs/thread/doc/changes.qbk

     
    2323* [@http://svn.boost.org/trac/boost/ticket/6226 #6226] c++11 compliance: Add explicit bool conversion from locks.
    2424* [@http://svn.boost.org/trac/boost/ticket/6228 #6228] Add promise constructor with allocator following the standard c++11.
    2525* [@http://svn.boost.org/trac/boost/ticket/6230 #6230] c++11 compliance: Follows the exception reporting mechanism as defined in the c++11.
     26* [@http://svn.boost.org/trac/boost/ticket/6266 #6266] Breaking change: thread destructor should call terminate if joinable.
     27* [@http://svn.boost.org/trac/boost/ticket/6269 #6269] Breaking change: thread move assignment should call terminate if joinable.
    2628* [@http://svn.boost.org/trac/boost/ticket/6272 #6272] c++11 compliance: Add thread::id hash specialization.
    2729* [@http://svn.boost.org/trac/boost/ticket/6273 #6273] c++11 compliance: Add cv_status enum class and use it on the conditions wait functions.
    2830* [@http://svn.boost.org/trac/boost/ticket/6231 #6231] Add BasicLockable requirements in the documentation to follow c++11.
    2931* [@http://svn.boost.org/trac/boost/ticket/6671 #6671] upgrade_lock: missing mutex and release functions.
    3032* [@http://svn.boost.org/trac/boost/ticket/6672 #6672] upgrade_lock:: missing constructors from time related types.
    3133* [@http://svn.boost.org/trac/boost/ticket/6675 #6675] upgrade_lock:: missing non-member swap.
     34
    3235       
    3336Fixed Bugs:
    3437
     
    176179# Complete the C++11 missing features, in particular
    177180
    178181  * [@http://svn.boost.org/trac/boost/ticket/4710 #4710] Missing async().
    179   * [@http://svn.boost.org/trac/boost/ticket/6266 #6266] Breaking change: thread destructor should call terminate if joinable.
    180   * [@http://svn.boost.org/trac/boost/ticket/6269 #6269] Breaking change: thread move assignment should call terminate if joinable.
    181182  * [@http://svn.boost.org/trac/boost/ticket/6342 #6342] Breaking change: Adapt the one_flag and call_once to the c++11 interface.
    182183
    183184  * [@http://svn.boost.org/trac/boost/ticket/6227 #6227] Use of variadic templates on Generic Locking Algorithms on compilers providing them.
  • libs/thread/src/win32/thread.cpp

     
    271271
    272272    }
    273273
    274     thread::~thread()
    275     {
    276         detach();
    277     }
    278 
    279274    thread::id thread::get_id() const BOOST_NOEXCEPT
    280275    {
    281276        return thread::id((get_thread_info)());
  • libs/thread/src/pthread/thread.cpp

     
    244244        }
    245245    }
    246246
    247     thread::~thread()
    248     {
    249         detach();
    250     }
    251247
     248
    252249    detail::thread_data_ptr thread::get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const
    253250    {
    254251        return thread_info;