Skip to content
Snippets Groups Projects
Commit 4fb780d1 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

locking.LockSet: Use function to get member lock name


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 049088b2
No related branches found
No related tags found
No related merge requests found
......@@ -731,7 +731,7 @@ class LockSet:
self.__lockdict = {}
for mname in members:
self.__lockdict[mname] = SharedLock("%s/%s" % (name, mname))
self.__lockdict[mname] = SharedLock(self._GetLockName(mname))
# The owner dict contains the set of locks each thread owns. For
# performance each thread can access its own key without a global lock on
......@@ -742,6 +742,12 @@ class LockSet:
# will be trouble.
self.__owners = {}
def _GetLockName(self, mname):
"""Returns the name for a member lock.
"""
return "%s/%s" % (self.name, mname)
def _is_owned(self):
"""Is the current thread a current level owner?"""
return threading.currentThread() in self.__owners
......@@ -1049,7 +1055,7 @@ class LockSet:
(invalid_names, self.name))
for lockname in names:
lock = SharedLock("%s/%s" % (self.name, lockname))
lock = SharedLock(self._GetLockName(lockname))
if acquired:
lock.acquire(shared=shared)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment