Tim Wiederhake d00d078968 virthread: Introduce virLockGuard
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@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-02-01 17:19:23 +01:00
..
2021-10-21 17:34:04 +01:00
2021-11-08 14:32:32 +01:00
2021-12-13 14:44:01 +01:00
2021-03-02 09:50:19 +01:00
2021-12-01 13:53:12 +01:00
2021-12-13 14:44:01 +01:00
2021-04-13 17:00:38 +02:00
2021-03-02 09:50:19 +01:00
2021-12-01 13:53:12 +01:00
2021-12-10 16:36:24 +01:00
2021-10-21 17:34:04 +01:00
2021-11-23 12:51:09 +01:00
2021-05-13 11:07:13 +01:00
2021-05-13 11:07:13 +01:00
2021-12-01 13:53:12 +01:00
2022-02-01 17:19:23 +01:00
2022-02-01 17:19:23 +01:00
2021-12-01 14:36:29 +01:00
2021-04-13 17:00:38 +02:00
2021-04-13 17:00:38 +02:00
2022-01-19 13:57:59 +01:00
2022-01-19 13:57:59 +01:00
2020-12-04 16:24:19 +01:00
2020-12-04 16:24:19 +01:00