From 39a0dc211e494b180c3d5e52ca7d48f53f87800c Mon Sep 17 00:00:00 2001 From: Georgi Koyrushki Date: Fri, 15 Mar 2024 11:21:39 +0000 Subject: [PATCH] Implement next() with read_scheduler, remove async_scope, map generator states to S/R operations --- include/unifex/async_generator.hpp | 542 ++++++++++------------------- test/async_generator_test.cpp | 47 ++- 2 files changed, 228 insertions(+), 361 deletions(-) diff --git a/include/unifex/async_generator.hpp b/include/unifex/async_generator.hpp index 3636e316..1bb9e0d5 100644 --- a/include/unifex/async_generator.hpp +++ b/include/unifex/async_generator.hpp @@ -22,8 +22,8 @@ # include # include -# include # include +# include # include # include # include @@ -40,240 +40,179 @@ template class async_generator; namespace detail { -template -class async_generator_iterator; -class async_generator_yield_operation; -class async_generator_advance_operation; - -class async_generator_promise_base { -public: - async_generator_promise_base() noexcept : m_exception(nullptr) { - // Other variables left intentionally uninitialised as they're - // only referenced in certain states by which time they should - // have been initialised. - } - - async_generator_promise_base(const async_generator_promise_base& other) = - delete; - async_generator_promise_base& - operator=(const async_generator_promise_base& other) = delete; - - std::suspend_always initial_suspend() const noexcept { return {}; } - async_generator_yield_operation final_suspend() noexcept; +// TODO: read_scheduler should be generalized to the read() sender factory from +// p2300, so we can do things like read(get_scheduler), read(get_stop_token), +// etc. +struct _read_scheduler_sender { + template < + template + class Variant, + template + class Tuple> + using value_types = Variant>; + + template