From: Stefan Hajnoczi <stefanha@gmail.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, kwolf@redhat.com,
ehabkost@redhat.com, mreitz@redhat.com, stefanha@redhat.com,
crosa@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [RFC PATCH] coroutines: generate wrapper code
Date: Mon, 11 Feb 2019 11:42:31 +0800 [thread overview]
Message-ID: <20190211034231.GD18083@stefanha-x1.localdomain> (raw)
In-Reply-To: <20190208141122.53046-1-vsementsov@virtuozzo.com>
[-- Attachment #1: Type: text/plain, Size: 1214 bytes --]
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2019-02-11 3:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 14:11 [Qemu-devel] [RFC PATCH] coroutines: generate wrapper code Vladimir Sementsov-Ogievskiy
2019-02-08 14:13 ` Vladimir Sementsov-Ogievskiy
2019-02-11 3:42 ` Stefan Hajnoczi [this message]
2019-02-11 9:38 ` [Qemu-devel] [Qemu-block] " Vladimir Sementsov-Ogievskiy
2019-02-12 3:22 ` Stefan Hajnoczi
2019-02-12 10:03 ` Vladimir Sementsov-Ogievskiy
2019-02-12 10:55 ` Stefan Hajnoczi
2019-02-12 11:58 ` Kevin Wolf
2019-02-13 6:58 ` Stefan Hajnoczi
2019-02-13 10:09 ` Kevin Wolf
2019-02-14 2:14 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190211034231.GD18083@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).