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: Paolo Bonzini
Subject: Re: [PATCH 0/2] thread: add lock guard macros
Date: Wed, 11 Mar 2020 13:52:35 +0100



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).

Paolo


Stefan Hajnoczi (2):
  thread: add QemuRecMutex lock guards
  thread: add QemuMutex lock guards

 include/qemu/thread.h | 52 +++++++++++++++++++++++++++++++++++++++++++
 plugins/core.c        |  6 ++---
 plugins/loader.c      | 15 ++++++-------
 util/qemu-timer.c     | 22 +++++++++---------
 4 files changed, 71 insertions(+), 24 deletions(-)

--
2.24.1


reply via email to

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