This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++0x] n2880 do not detach std::thread by default


2009/6/16 Paolo Carlini:
> Jonathan Wakely wrote:
>> n2880 changed the behaviour of std::thread so that it calls
>> std::terminate() if the thread is joinable when destroyed or assigned
>> to.
>>
>> I want to commit this to trunk and 4.4, but what's the best way to
>> test it? (all current tests pass, because they always explicitly
>> join() or detach() thread objects.)
>>
> I would say, for now let's commit the update itself to both mainline and
> branch. ?If you think testing would be important, just add a one line
> reminder right above the change.

OK, I don't think it's essential to test std::terminate works :-)  so
I committed what I sent originally (repeated below for gcc-patches.)
Tested x86_64/linux.

Thanks.

Jon

        * include/std/thread (~thread(), operator=(thread&&)): Call terminate
        if joinable.

Index: include/std/thread
===================================================================
--- include/std/thread  (revision 148549)
+++ include/std/thread  (working copy)
@@ -135,7 +135,7 @@ namespace std
     ~thread()
     {
       if (joinable())
-       detach();
+       std::terminate();
     }

     thread& operator=(const thread&) = delete;
@@ -143,7 +143,7 @@ namespace std
     thread& operator=(thread&& __t)
     {
       if (joinable())
-       detach();
+       std::terminate();
       swap(__t);
       return *this;
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]