mozilla::MutexAutoUnlock

mozilla::MutexAutoUnlock is an RAII helper for mozilla::Mutex. It is designed to make using mozilla::Mutex safer and easier. To use mozilla::MutexAutoUnlock, declare and initialize it with a reference to a locked mozilla::Mutex. The mozilla::MutexAutoUnlock constructor will Unlock() the underlying mozilla::Mutex automatically. When the mozilla::MutexAutoUnlock goes out of scope, its destructor will Lock() the underlying mozilla::Mutex.

Because of mozilla::MutexAutoLock, the rule for determining if your code does not own the Mutex underlying the MutexAutoUnlock is slightly more complicated than that for MonitorAutoEnter. This is because MutexAutoUnlocks can be nested within MutexAutoLocks and vice versa, indefinitely deeply.

Important: When a mozilla::MutexAutoUnlock is the Mutex RAII wrapper most recently pushed on the stack, your code is guaranteed not to own the underlying mozilla::Mutex.

Constructors

MutexAutoUnlock(
    in mozilla::Mutex& lock;
);

This parameter is a reference so as to guarantee that your code has already properly constructed the mozilla::Mutex.

Methods

None.

See also

 

Document Tags and Contributors

Contributors to this page: cgj
Last updated by: cgj,