================
@@ -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:
What I meant was that you don't need the *Target*APILock class as this can be
implemented generically in the APILock base class (although it looks like my
snippet https://github.com/llvm/llvm-project/pull/131404/files#r1998175315
still calls this TargetAPILock). I.e., you could do something like:
```
class APILock {
APILock(std::shared_ptr<std::recursive_mutex> mutex) :
m_mutex(std::move(mutex)), m_lock(*m_mutex) {}
private:
std::shared_ptr<std::recursive_mutex> m_mutex;
std::lock_guard<std::recursive_mutex> m_lock;
};
```
and this can be used with anything that can turn itself into a shared pointer
(using the aliasing constructor)
https://github.com/llvm/llvm-project/pull/131404
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits