mozilla::MutexAutoLock

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

Because of mozilla::MutexAutoUnlock, the rule for determining if your code owns the Mutex underlying the MutexAutoLock 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::MutexAutoLock is the Mutex RAII wrapper most recently pushed on the stack, your code is guaranteed to own the underlying mozilla::Mutex.

Constructors

MutexAutoLock(
    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