Francesco Romani has posted comments on this change.
Change subject: rwlock: Add simpler RWLock
......................................................................
Patch Set 10: Code-Review+1
(3 comments)
looks ok and looks nice. Comments inside about possible very minor improvements.
https://gerrit.ovirt.org/#/c/42908/10/lib/vdsm/rwlock.py
File lib/vdsm/rwlock.py:
Line 28:
Line 29: This lock is not prefering writers or readers. Each acquire request is put
Line 30: into a queue, and will be served in the order of the request.
Line 31:
Line 32: To acquire a write lock, use acquire_write(), followed by relase() when you
typo: release
Line 33: are done.
Line 34:
Line 35: lock.acquire_write()
Line 36:
Line 75: Lock promotion or demotion is forbidden and will raise RuntimeError.
Line 76: """
Line 77:
Line 78: def __init__(self):
Line 79: self.shared = Context(self, False)
very minor: perhaps using an (unneeded) named argument makes the code a tiny bit nicer:
self.shared = Context(self, exclusive=False)
self.exclusive = Context(self, exclusive=True)
OTOH, the repetition of "exclusive" can be ugly?
Line 80: self.exclusive = Context(self, True)
Line 81: self._lock = threading.Lock()
Line 82: self._waiters = []
Line 83: self._readers = set()
Line 90: if me is self._writer:
Line 91: raise RuntimeError("Recursive lock is forbidden")
Line 92: with self._lock:
Line 93: if self._writer or self._readers or self._waiters:
Line 94: self._wait(True)
same (and below on line 105). Maybe
self._wait(wants_write=True)
or maybe too verbose?
Line 95: self._writer = me
Line 96:
Line 97: def acquire_read(self):
Line 98: me = threading.current_thread()
--
To view, visit
https://gerrit.ovirt.org/42908
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I2466c137c89598772fb46347eb02195916883cac
Gerrit-PatchSet: 10
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Adam Litke <alitke(a)redhat.com>
Gerrit-Reviewer: Ala Hino <ahino(a)redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Dima Kuznetsov <dkuznets(a)redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Freddy Rolland <frolland(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-HasComments: Yes