================
@@ -0,0 +1,11 @@
+%extend lldb::SBLock {
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ self.Unlock()
----------------
vogelsgesang wrote:
It's a bit unfortunate, that
```
lock = target.AcquireLock();
with lock:
# we are correctly locked here
with lock:
# we are no longer locked here :/
```
does not work as expected.
In Python, the convention seems to be that locks can be locked or unlocked, and
entering a `with` scope` acquires the lock. We might want to model this after
the Python's
[Lock](https://docs.python.org/3/library/threading.html#lock-objects) or
[RLock](std::unique_lock) objects, i.e. closer to a `std::unique_lock` than a
`std::lock_guard`
WDYT?
https://github.com/llvm/llvm-project/pull/131404
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits