If you are familiar with C interfaces for locks, you may be wondering
why there are not simply acquire and release methods on the mutex object
itself. The reason is that the C interface would not be exception safe,
because if the protected region threw an exception, control would skip
over the release. With the object-oriented interface, destruction of the
object causes the lock to be released, no matter whether
the protected region was exited by normal control flow or an exception.
This is true even for our version of
that used methods
the explicit release causes the lock to be
released earlier, and the destructor then sees that the lock was
released and does nothing.