]> xenbits.xensource.com Git - libvirt.git/commit
virobject: Introduce virObjectRWLockable
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 19 Jul 2017 07:31:50 +0000 (09:31 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 24 Jul 2017 13:54:06 +0000 (15:54 +0200)
commit77f4593b094802140281ad55167fe64ef1a986af
tree48d051a0f532dbb34ba9027626c59903613af6d4
parent328bd24443d2a345a5832ee48ebba0208f8036ea
virobject: Introduce virObjectRWLockable

Up until now we only had virObjectLockable which uses mutexes for
mutually excluding each other in critical section. Well, this is
not enough. Future work will require RW locks so we might as well
have virObjectRWLockable which is introduced here.

Moreover, polymorphism is introduced to our code for the first
time. Yay! More specifically, virObjectLock will grab a write
lock, virObjectLockRead will grab a read lock then (what a
surprise right?). This has great advantage that an object can be
made derived from virObjectRWLockable in a single line and still
continue functioning properly (mutexes can be viewed as grabbing
write locks only). Then just those critical sections that can
grab a read lock need fixing. Therefore the resulting change is
going to be way smaller.

In order to avoid writer starvation, the object initializes RW
lock that prefers writers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/libvirt_private.syms
src/util/virobject.c
src/util/virobject.h