Section: 220.127.116.11 [thread.thread.member] Status: C++11 Submitter: Alberto Ganesh Barbati Opened: 2009-03-12 Last modified: 2016-02-10
Priority: Not Prioritized
View all other issues in [thread.thread.member].
View all issues with C++11 status.
While looking at thread::join() I think I spotted a couple of possible defects in the specifications. I could not find a previous issue or NB comment about that, but I might have missed it.
The postconditions clause for thread::join() is:
Postconditions: If join() throws an exception, the value returned by get_id() is unchanged. Otherwise, get_id() == id().
and the throws clause is:
Throws: std::system_error when the postconditions cannot be achieved.
Now... how could the postconditions not be achieved? It's just a matter of resetting the value of get_id() or leave it unchanged! I bet we can always do that. Moreover, it's a chicken-and-egg problem: in order to decide whether to throw or not I depend on the postconditions, but the postconditions are different in the two cases.
I believe the throws clause should be:
Throws: std::system_error when the effects or postconditions cannot be achieved.
as it is in detach(), or, even better, as the postcondition is trivially satisfiable and to remove the circular dependency:
Throws: std::system_error if the effects cannot be achieved.
Problem is that... ehm... join() has no "Effects" clause. Is that intentional?
[ See the thread starting at c++std-lib-23204 for more discussion. ]
[ Batavia (2009-05): ]
Pete believes there may be some more general language (in frontmatter) that can address this and related issues such as 962.
Move to Open.
[ 2009-11-18 Anthony provides wording. ]
[ 2010-02-12 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
Edit 18.104.22.168 [thread.thread.member] as indicated:
5 Precondition: joinable() is true.
6 Synchronization: The completion of the thread represented by *this happens before (6.8.2 [intro.multithread]) join() returns. [Note: Operations on *this are not synchronized. — end note]
If join() throws an exception, the value returned by get_id() is unchanged. Otherwise,get_id() == id().