In order to maintain locking invariants in a multi-threaded system, a
special inverse lock class is defined whose constructor stores a reference
to, and then releases, a previously-acquired lock whose reference is
passed into it. The destructor of the class re-acquires the referenced
lock. During operation, the class is instantiated, passing in the desired
lock before an upcall is made. Instantiation executes the constructor and
causes the lock to be released. When the upcall terminates, either
normally or by an exception, the inverse lock object destructor is
executed causing the lock to be re-acquired. Since the inverse lock object
destructor will always be called when the object is destroyed, the locking
invariant will always be satisfied.