qemu-devel
[Top][All Lists]
Advanced

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

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


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation
Date: Mon, 11 Dec 2017 10:16:20 +0000
User-agent: Mutt/1.9.1 (2017-09-22)

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 and documented.  Move the
> > implementation out of the way and mark it private.  That will make it
> > easier for someone to figure out "how do I use lock-guard.h".
> 
> Right, unfortunately you pretty much have to place it in the header to
> guarantee that everything is inlined.

Yes, that's fine.  I think the important part is to put public
interfaces next to each other and document them.

> >> +#define QEMU_WITH_LOCK(type, name, lock)                                  
> >>  \
> >> +    for (QEMU_LOCK_GUARD(type, name, lock);                               
> >>  \
> >> +         qemu_lock_guard_is_taken(&name);                                 
> >>  \
> >> +         qemu_lock_guard_unlock(&name))
> > 
> > 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 infinite loop. :)

Sorry, I mean for (...; false; ...).  Is there any reason to do
qemu_lock_guard_is_taken(&name)?

Attachment: signature.asc
Description: PGP signature


reply via email to

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