Locking: add ssynchronized decorator
authorGuido Trotter <ultrotter@google.com>
Tue, 8 Jul 2008 08:40:42 +0000 (08:40 +0000)
committerGuido Trotter <ultrotter@google.com>
Tue, 8 Jul 2008 08:40:42 +0000 (08:40 +0000)
commit42a999d1a3bbf9911dd2de149b02ad5354dd8261
tree691fa740e0f7b156f5c862221ff5fe30e9fceec4
parent5b4cd1b01e0b266f20d2ff12d360912ea4bb110a
Locking: add ssynchronized decorator

This patch creates a new decorator function ssynchronized in the locking
library, which takes as input a SharedLock, and synchronizes access to
the decorated functions using it. The usual SharedLock semantics apply,
so it's possible to call more than one synchronized function at the same
time, when the lock is acquired in shared mode, and still protect
against exclusive access.

The patch also adds a few unit test to check the basic decorator's
functionality, and to provide an example on how to use it.

Reviewed-by: iustinp
lib/locking.py
test/ganeti.locking_unittest.py