qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/2] thread: add lock guard macros


From: Stefan Hajnoczi
Subject: Re: [PATCH 0/2] thread: add lock guard macros
Date: Wed, 11 Mar 2020 17:06:25 +0000

On Wed, Mar 11, 2020 at 01:52:35PM +0100, Paolo Bonzini wrote:
> Il mer 11 mar 2020, 13:38 Stefan Hajnoczi <address@hidden> 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

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]