Change in vdsm[master]: misc: Simplify DynamicBarrier implemenation

danken at redhat.com danken at redhat.com
Tue Jun 24 16:43:49 UTC 2014


Dan Kenigsberg has submitted this change and it was merged.

Change subject: misc: Simplify DynamicBarrier implemenation
......................................................................


misc: Simplify DynamicBarrier implemenation

DynamicBarrier uses a threading.Condition. The condition
already contain a lock, used to synchronize enter() and exit().

Within the critical sections in enter() and exit(), only one thread can
run. When a thread call self._cond.wait(), the condition lock is
released atomically and the next thread waiting on the condition lock
continue to run. When a thread return from self.cond.wait(), it get the
condition lock and run, while all other threads are waiting on the
condition lock. This is ensured by threading.Condition, both Python
builtin and pthread_cond when using pthreading.

To keep a boolean state of the barrier, we don't need another lock, a
boolean is just fine.

Previously, when trying to exit a barrier without entering it, a
ThreadError was raised:

    thread.error: release unlocked lock

Now a more specific and useful message is raised:

    AssertionError: Attempt to exit a barrier without entering

Change-Id: Ia403cd9f734eaafdce95ba5123e54ec4e4939172
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/29003
Reviewed-by: Saggi Mizrahi <smizrahi at redhat.com>
---
M vdsm/storage/misc.py
1 file changed, 7 insertions(+), 4 deletions(-)

Approvals:
  Nir Soffer: Verified
  Saggi Mizrahi: Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/29003
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia403cd9f734eaafdce95ba5123e54ec4e4939172
Gerrit-PatchSet: 5
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list