77f4593 virobject: Introduce virObjectRWLockable

Authored and Committed by mprivozn 6 years ago
    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>
    
        
file modified
+3 -0
file modified
+112 -31
file modified
+16 -0