On Wed, Mar 11, 2020 at 01:52:35PM +0100, Paolo Bonzini wrote: > Il mer 11 mar 2020, 13:38 Stefan Hajnoczi <[email protected]> ha scritto: > > > Lock guards automatically call qemu_(rec_)mutex_unlock() when returning > > from a > > function or leaving leaving a lexical scope. This simplifies code and > > eliminates leaks (especially in error code paths). > > > > This series adds lock guards for QemuMutex and QemuRecMutex. It does not > > convert the entire tree but includes example conversions. > > > > Thanks for picking this up! It should be possible to use QemuLockable to > introduce a single set of lock guard macros that work for mutexes, > spinlocks and CoMutexes. Would you look into that? > > (C++ also has unique_lock, a kind of lock guard that can be unlocked early > and won't cause a double unlock, and also can be created unlocked. However > it makes sense to not implement that unless one has a killer application of > it in the tree).
I already looked at lockable.h and to be honest I didn't want to combine g_autoptr macros with lockable's polymorphism macros. However, since you have mentioned it I'll take another look and try to overcome the aversion :). Stefan
signature.asc
Description: PGP signature
