Title
Remove unnecessary preconditions from unique_lock constructor
Status
c++11
Section
[thread.lock.unique.cons]
Submitter
Alisdair Meredith

Created on 2009-03-12.00:00:00 last changed 154 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Strike [thread.lock.unique.cons] p7:

unique_lock(mutex_type& m, defer_lock_t);

-7- Precondition: If mutex_type is not a recursive mutex the calling thread does not own the mutex.

Date: 2010-10-21.18:28:33

[ Batavia (2009-05): ]

We agree with the proposed resolution. Move to Tentatively Ready.

Date: 2010-10-21.18:28:33

[ Summit: ]

Agree, move to review.

Date: 2012-10-21.13:19:07

Addresses UK 326 [CD1]

The precondition that the mutex is not owned by this thread offers introduces the risk of unnecessary undefined behaviour into the program. The only time it matters whether the current thread owns the mutex is in the lock operation, and that will happen subsequent to construction in this case. The lock operation has the identical pre-condition, so there is nothing gained by asserting that precondition earlier and denying the program the right to get into a valid state before calling lock.

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-10-21 18:28:33adminsetmessages: + msg471
2010-10-21 18:28:33adminsetmessages: + msg470
2010-10-21 18:28:33adminsetmessages: + msg469
2009-03-12 00:00:00admincreate