[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH experiment 14/16] util: introduce C++ stackless coroutine bac
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH experiment 14/16] util: introduce C++ stackless coroutine backend |
Date: |
Mon, 14 Mar 2022 14:37:15 +0000 |
On Mon, Mar 14, 2022 at 10:32:01AM +0100, Paolo Bonzini wrote:
> +// ------------------------
> +
> +// CoroutineFn does not even need anything more than what
> +// BaseCoroutine provides, so it's just a type alias. The magic
> +// is all in ValuePromise<T>.
> +//
> +// Suspended CoroutineFns are chained between themselves. Whenever a
> +// coroutine is suspended, all those that have done a co_await are
> +// also suspended, and whenever a coroutine finishes, it has to
> +// check if its parent can now be resumed.
> +//
> +// The two auxiliary classes Awaiter and ResumeAndFinish take
> +// care of the two sides of this. Awaiter's await_suspend() stores
> +// the parent coroutine into ValuePromise; ResumeAndFinish's runs
> +// after a coroutine returns, and resumes the parent coroutine.
> +
> +template<typename T> struct ValuePromise;
> +template<typename T>
> +using CoroutineFn = BaseCoroutine<ValuePromise<T>>;
> +
> +typedef CoroutineFn<void> CoroutineFunc(void *);
CoroutineFunc looks like a coroutine entry point function. If that's
correct then I suggest naming it CoroutineEntryFunc to avoid confusion
between CoroutineFn vs CoroutineFunc (their names are too similar).
Also, where is CoroutineFunc used?
> +// The actu promises, respectively for non-void and void types.
s/actu/actual/?
signature.asc
Description: PGP signature
- [PATCH experiment 02/16] coroutine: qemu_coroutine_get_aio_context is not a coroutine_fn, (continued)
- [PATCH experiment 02/16] coroutine: qemu_coroutine_get_aio_context is not a coroutine_fn, Paolo Bonzini, 2022/03/14
- [PATCH experiment 03/16] coroutine: small code cleanup in qemu_co_rwlock_wrlock, Paolo Bonzini, 2022/03/14
- [PATCH experiment 05/16] port atomic.h to C++, Paolo Bonzini, 2022/03/14
- [PATCH experiment 07/16] start porting compiler.h to C++, Paolo Bonzini, 2022/03/14
- [PATCH experiment 13/16] disable some code, Paolo Bonzini, 2022/03/14
- [PATCH experiment 12/16] remove "new" keyword from trace-events, Paolo Bonzini, 2022/03/14
- [PATCH experiment 16/16] port test-coroutine to C++ coroutines, Paolo Bonzini, 2022/03/14
- [PATCH experiment 14/16] util: introduce C++ stackless coroutine backend, Paolo Bonzini, 2022/03/14
- Re: [PATCH experiment 14/16] util: introduce C++ stackless coroutine backend,
Stefan Hajnoczi <=
- [PATCH experiment 10/16] add space between liter and string macro, Paolo Bonzini, 2022/03/14
- [PATCH experiment 04/16] coroutine: introduce QemuCoLockable, Paolo Bonzini, 2022/03/14
- [PATCH experiment 06/16] use g_new0 instead of g_malloc0, Paolo Bonzini, 2022/03/14
- [PATCH experiment 08/16] tracetool: add extern "C" around generated headers, Paolo Bonzini, 2022/03/14
- [PATCH experiment 09/16] start adding extern "C" markers, Paolo Bonzini, 2022/03/14
- [PATCH experiment 11/16] bump to C++20, Paolo Bonzini, 2022/03/14