Allow to defer lock on ObjectLock

This commit is contained in:
Yonas Habteab 2025-07-03 12:14:31 +02:00
parent 455d6fcde1
commit 4c0628c24d
2 changed files with 13 additions and 0 deletions

View File

@ -18,6 +18,18 @@ ObjectLock::ObjectLock(const Object::Ptr& object)
{
}
/**
* Constructs a lock for the given object without locking it immediately.
*
* The user must call Lock() explicitly when needed.
*
* @param object The object to lock.
*/
ObjectLock::ObjectLock(const Object::Ptr& object, std::defer_lock_t)
: m_Object(object.get()), m_Locked(false)
{
}
ObjectLock::ObjectLock(const Object *object)
: m_Object(object), m_Locked(false)
{

View File

@ -15,6 +15,7 @@ struct ObjectLock
{
public:
ObjectLock(const Object::Ptr& object);
ObjectLock(const Object::Ptr& object, std::defer_lock_t);
ObjectLock(const Object *object);
ObjectLock(const ObjectLock&) = delete;