================
@@ -1692,6 +1692,20 @@ class Target : public 
std::enable_shared_from_this<Target>,
   }
 };
 
+/// The private implementation backing SBLock.
+struct APILock {
+  APILock(std::recursive_mutex &mutex) : lock(mutex) {}
+  std::lock_guard<std::recursive_mutex> lock;
+};
+
+/// The private implementation used by SBLock to hand out the target API mutex.
+/// It has a TargetSP to ensure the lock cannot outlive the target.
+struct TargetAPILock : public APILock {
----------------
labath wrote:
So, if all you want to do with this is to hold a shared pointer, then this can 
be done in a simpler way. You can have the class take a 
`std::shared_ptr<mutex>` and call this using the shared_ptr [aliasing 
constructor](https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr) 
from the shared pointer of your choice (e.g. 
`TargetAPILock(std::shared_ptr<mutex>(target_sp, target_sp->m_mutex))`)

https://github.com/llvm/llvm-project/pull/131404
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to