[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
signature.asc
Description: PGP signature
- [PATCH 0/2] thread: add lock guard macros, Stefan Hajnoczi, 2020/03/11
- [PATCH 1/2] thread: add QemuRecMutex lock guards, Stefan Hajnoczi, 2020/03/11
- [PATCH 2/2] thread: add QemuMutex lock guards, Stefan Hajnoczi, 2020/03/11
- Re: [PATCH 0/2] thread: add lock guard macros, Paolo Bonzini, 2020/03/11
- Re: [PATCH 0/2] thread: add lock guard macros,
Stefan Hajnoczi <=
- Re: [PATCH 0/2] thread: add lock guard macros, no-reply, 2020/03/11
- Re: [PATCH 0/2] thread: add lock guard macros, no-reply, 2020/03/11
- Re: [PATCH 0/2] thread: add lock guard macros, Markus Armbruster, 2020/03/11