|
@@ -299,6 +299,8 @@ class UpgradableLock:
|
|
self._roster.modify(SHARED, REMOVE)
|
|
self._roster.modify(SHARED, REMOVE)
|
|
|
|
|
|
def upgrade(self):
|
|
def upgrade(self):
|
|
|
|
+ # WARNING: if multiple read-lockers want to upgrade, it will deadlock because they
|
|
|
|
+ # all will wait until the other read locks go away - and that won't happen.
|
|
if not self.is_exclusive:
|
|
if not self.is_exclusive:
|
|
self.acquire(exclusive=True, remove=SHARED)
|
|
self.acquire(exclusive=True, remove=SHARED)
|
|
|
|
|
|
@@ -306,6 +308,9 @@ class UpgradableLock:
|
|
if self.is_exclusive:
|
|
if self.is_exclusive:
|
|
self.acquire(exclusive=False, remove=EXCLUSIVE)
|
|
self.acquire(exclusive=False, remove=EXCLUSIVE)
|
|
|
|
|
|
|
|
+ def got_exclusive_lock(self):
|
|
|
|
+ return self.is_exclusive and self._lock.is_locked() and self._lock.by_me()
|
|
|
|
+
|
|
def break_lock(self):
|
|
def break_lock(self):
|
|
self._roster.remove()
|
|
self._roster.remove()
|
|
self._lock.break_lock()
|
|
self._lock.break_lock()
|