qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-block] [RFC PATCH] coroutines: generate wrapper c


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [Qemu-block] [RFC PATCH] coroutines: generate wrapper code
Date: Mon, 11 Feb 2019 11:42:31 +0800
User-agent: Mutt/1.10.1 (2018-07-13)

On Fri, Feb 08, 2019 at 05:11:22PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Hi all!
> 
> We have a very frequent pattern of wrapping a coroutine_fn function
> to be called from non-coroutine context:
> 
>   - create structure to pack parameters
>   - create function to call original function taking parameters from
>     struct
>   - create wrapper, which in case of non-coroutine context will
>     create a coroutine, enter it and start poll-loop.
>
> Here is a draft of template code + example how it can be used to drop a
> lot of similar code.
> 
> Hope someone like it except me)

My 2 cents.  Cons:

 * Synchronous poll loops are an anti-pattern.  They block all of QEMU
   with the big mutex held.  Making them easier to write is
   questionable because we should aim to have as few of these as
   possible.

 * Code generation makes the code easier to write but harder to read.
   Code is read more than written.  In this case I think open coding
   isn't too bad and I prefer it to reading a code generation script to
   understand how it works.

If we were planning to add lots more of these then I agree code
generation would help.  But in this case I'd rather not.

Attachment: signature.asc
Description: PGP signature


reply via email to

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