Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Adding clarifying words

...

C++ supplies lock classes, lock_guard, unique_lock, and shared_lock, that can be initialized with a mutex. In its constructor, the lock object locks the mutex, and in its destructor, it unlocks the mutex. If The lock_guard class provides a simple RAII wrapper around a mutex. The unique_lock and shared_lock classes also use RAII, but provide additional functionality, such as manual control over the locking strategy and allowing ownership of the lock to safely transfer to another object. For all three classes, if an exception occurs and takes control flow out of the scope of the lock, its the destructor will unlock the mutex and the program can continue working normally. These lock objects are the preferred way to ensure that a mutex is properly released when an exception is thrown.

...