Re: [Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation

2017-12-12 Thread Stefan Hajnoczi
On Mon, Dec 11, 2017 at 07:51:43AM -0600, Eric Blake wrote: > On 12/11/2017 04:16 AM, Stefan Hajnoczi wrote: > > >>> I don't understand the need for the qemu_lock_guard_is_taken(&name) > >>> condition, why not do the following? > >>> > >>> for (QEMU_LOCK_GUARD(type, name, lock); > >>>; >

Re: [Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation

2017-12-11 Thread Eric Blake
On 12/11/2017 04:16 AM, Stefan Hajnoczi wrote: >>> I don't understand the need for the qemu_lock_guard_is_taken(&name) >>> condition, why not do the following? >>> >>> for (QEMU_LOCK_GUARD(type, name, lock); >>>; >>>qemu_lock_guard_unlock(&name)) >> >> Because that would be an in

Re: [Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation

2017-12-11 Thread Stefan Hajnoczi
On Fri, Dec 08, 2017 at 06:56:12PM +0100, Paolo Bonzini wrote: > On 08/12/2017 16:30, Stefan Hajnoczi wrote: > > On Fri, Dec 08, 2017 at 11:55:50AM +0100, Paolo Bonzini wrote: > > > > The implementation is somewhat complex. Please structure the header > > file so the public interfaces are clear a

Re: [Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation

2017-12-08 Thread Eric Blake
On 12/08/2017 11:56 AM, Paolo Bonzini wrote: >>> +typedef void QemuLockGuardFunc(void *); >>> +typedef struct QemuLockGuard { >>> +QemuLockGuardFunc *p_lock_fn, *p_unlock_fn; >>> +void *lock; >>> +int locked; >> >> bool? > > Yes. > >>> +#define QEMU_WITH_LOCK(type, name, lock)

Re: [Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation

2017-12-08 Thread Paolo Bonzini
On 08/12/2017 16:30, Stefan Hajnoczi wrote: > On Fri, Dec 08, 2017 at 11:55:50AM +0100, Paolo Bonzini wrote: > > The implementation is somewhat complex. Please structure the header > file so the public interfaces are clear and documented. Move the > implementation out of the way and mark it priv

Re: [Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation

2017-12-08 Thread Stefan Hajnoczi
On Fri, Dec 08, 2017 at 11:55:50AM +0100, Paolo Bonzini wrote: The implementation is somewhat complex. Please structure the header file so the public interfaces are clear and documented. Move the implementation out of the way and mark it private. That will make it easier for someone to figure o

[Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation

2017-12-08 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- include/qemu/coroutine.h | 4 ++ include/qemu/lock-guard.h | 99 +++ include/qemu/thread.h | 7 util/Makefile.objs| 1 + util/qemu-thread.c| 17 5 files changed, 128 insertions(+) c