aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2020-03-16 11:09:56 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2020-03-17 15:18:45 +0100
commit3284c3ddc48ba8fc853858c95d87dcc2ab160b29 (patch)
tree40c7c87cb3f7f0c3a8cb95d45ce3ee26f06dd1e0 /plugins
parent8834dcf47e8543b92e072706d3a5621762bfa106 (diff)
lockable: add lock guards
This patch introduces two lock guard macros that automatically unlock a lock object (QemuMutex and others): void f(void) { QEMU_LOCK_GUARD(&mutex); if (!may_fail()) { return; /* automatically unlocks mutex */ } ... } and: WITH_QEMU_LOCK_GUARD(&mutex) { if (!may_fail()) { return; /* automatically unlocks mutex */ } } /* automatically unlocks mutex here */ ... Convert qemu-timer.c functions that benefit from these macros as an example. Manual qemu_mutex_lock/unlock() callers are left unmodified in cases where clarity would not improve by switching to the macros. Many other QemuMutex users remain in the codebase that might benefit from lock guards. Over time they can be converted, if that is desirable. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> [Use QEMU_MAKE_LOCKABLE_NONNULL. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'plugins')
0 files changed, 0 insertions, 0 deletions