|
RMM API 2.0.0
|
A RAII wrapper for an optional std::mutex. This class provides a way to lock a mutex only if a valid pointer is provided. If the pointer is null, the lock and unlock operations do nothing, allowing for flexible locking strategies where a mutex may or may not exist. More...
#include <OptionalLock.h>
Public Member Functions | |
| OptionalLock (std::mutex *m) | |
| Constructs the lock and automatically locks the mutex if it exists. | |
| ~OptionalLock () | |
| Destructor that automatically unlocks the mutex if it exists. | |
| void | unlock () |
| Manually unlocks the mutex if it is not null. | |
| void | lock () |
| Manually locks the mutex if it is not null. | |
A RAII wrapper for an optional std::mutex. This class provides a way to lock a mutex only if a valid pointer is provided. If the pointer is null, the lock and unlock operations do nothing, allowing for flexible locking strategies where a mutex may or may not exist.
|
inline |
Constructs the lock and automatically locks the mutex if it exists.
| m | Pointer to the std::mutex to manage. Can be nullptr. |