Is unique_lock :: unlock underspecified in C ++ 11?

The C ++ 11 standard defines unique_lock::unlockhow (ยง 30.4.2.2.2, p. 1159)

void unlock();
Effects: pm->unlock()
Postcondition: owns == false
Throws: system_error when an exception is required (30.2.2).
Error conditions:
  โ€” operation_not_permitted โ€” if on entry owns is false.

All other blocking operations indicate that an exception is raised in at least two cases:

  • Mutex is NULL (throws system_errorwith errc::operation_not_permitted)
  • Mutex is already locked (throws system_errorusing errc::operation_not_permitted)

The problem with an invalid mutez is obviously possible for unlock, however, the standard indicates the behavior of the program only for problems with blocking. Is this a real mistake in the standard or am I missing something?

+5
source share
2 answers

, unique_lock :

if pm == nullptr then owns == false
if owns == true then pm != nullptr

unique_lock , , undefined. , :

โ€” operation_not_permitted โ€” if on entry owns is false.

, pm == nullptr.

, ~unique_lock() pm->unlock(), owns - true. owns , pm != nullptr , , unlock() .

+7

pm - mutex_type, std::mutex:

void unlock() noexcept;

, unlock - , unique_lock::unlock - . , - , .

, unique_lock ( , unlock, ). , - . , - , .

- .

, , .

0

All Articles