Re: [libvirt PATCH v5 2/9] virthread: Introduce virLockGuard

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

 



On Tue, Feb 01, 2022 at 02:20:10PM +0100, Tim Wiederhake wrote:
> Locks a virMutex on creation and unlocks it in its destructor.
> 
> The VIR_LOCK_GUARD macro is used instead of "g_auto(virLockGuard)" to
> work around a clang issue (see https://bugs.llvm.org/show_bug.cgi?id=3888
> and https://bugs.llvm.org/show_bug.cgi?id=43482).
> 
> Typical usage:
> 
>     void function(virMutex *m)
>     {
>         VIR_LOCK_GUARD lock = virLockGuardLock(m);
>         /* `m` is locked, and released automatically on scope exit */
> 
>         ...
>         while (expression) {
>             VIR_LOCK_GUARD lock2 = virLockGuardLock(...);
>             /* similar */
>         }
>     }
> 
> Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
> ---
>  src/libvirt_private.syms |  2 ++
>  src/util/virthread.c     | 15 +++++++++++++++
>  src/util/virthread.h     | 10 ++++++++++
>  3 files changed, 27 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux