diff --git a/CMakeLists.txt b/CMakeLists.txt index c333b94..51b5e44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ FetchContent_Declare( execution # FETCHCONTENT_SOURCE_DIR_EXECUTION ${CMAKE_SOURCE_DIR}/../execution GIT_REPOSITORY https://github.com/bemanproject/execution - GIT_TAG 09d5a5c + GIT_TAG cad563e SYSTEM FIND_PACKAGE_ARGS 0.2.0 diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a1539d0..8dda33e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -34,7 +34,6 @@ if(NOT MSVC) task-sender alloc-1 alloc-2 - bulk c++now-allocator c++now-cancel c++now-errors diff --git a/examples/bulk.cpp b/examples/bulk.cpp index 338e400..aabb167 100644 --- a/examples/bulk.cpp +++ b/examples/bulk.cpp @@ -7,8 +7,6 @@ namespace ex = beman::execution; namespace beman::execution { -inline constexpr struct par_t { -} par{}; using parallel_scheduler = inline_scheduler; } // namespace beman::execution diff --git a/include/beman/task/detail/inline_scheduler.hpp b/include/beman/task/detail/inline_scheduler.hpp deleted file mode 100644 index c6f4b11..0000000 --- a/include/beman/task/detail/inline_scheduler.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// include/beman/task/detail/inline_scheduler.hpp -*-C++-*- -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef INCLUDED_BEMAN_TASK_DETAIL_INLINE_SCHEDULER -#define INCLUDED_BEMAN_TASK_DETAIL_INLINE_SCHEDULER - -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- - -namespace beman::task::detail { -/*! - * \brief Scheduler completing immediately when started on the same thread - * \headerfile beman/task/task.hpp - * - * The class `inline_scheduler` is used to prevent any actual schedulering. - * It does have a scheduler interface but it completes synchronously on - * the thread on which it gets `start`ed before returning from `start`. - * The implication is that any blocking working gets executed on the - * calling thread. Also, if there is lot of synchronous work repeatedly - * getting scheduled using `inline_scheduler` it is possible to get a - * stack overflow. - * - * In general, any use of `inline_scheduler` should receive a lot of - * attention as it is fairly easy to create subtle bugs using this scheduler. - */ -struct inline_scheduler { - struct env { - inline_scheduler - query(const ::beman::execution::get_completion_scheduler_t<::beman::execution::set_value_t>&) const noexcept { - return {}; - } - }; - template <::beman::execution::receiver Receiver> - struct state { - using operation_state_concept = ::beman::execution::operation_state_t; - std::remove_cvref_t receiver; - void start() & noexcept { ::beman::execution::set_value(std::move(receiver)); } - }; - struct sender { - using sender_concept = ::beman::execution::sender_t; - using completion_signatures = ::beman::execution::completion_signatures<::beman::execution::set_value_t()>; - template - static consteval auto get_completion_signatures() noexcept -> completion_signatures { - return {}; - } - - env get_env() const noexcept { return {}; } - template <::beman::execution::receiver Receiver> - state connect(Receiver&& receiver) { - return {std::forward(receiver)}; - } - }; - static_assert(::beman::execution::sender); - - using scheduler_concept = ::beman::execution::scheduler_t; - constexpr sender schedule() noexcept { return {}; } - bool operator==(const inline_scheduler&) const = default; -}; -static_assert(::beman::execution::scheduler); -static_assert(::beman::execution::scheduler<::beman::task::detail::inline_scheduler>); -} // namespace beman::task::detail - -// ---------------------------------------------------------------------------- - -#endif diff --git a/include/beman/task/detail/promise_env.hpp b/include/beman/task/detail/promise_env.hpp index 7b7a4ae..41f8b68 100644 --- a/include/beman/task/detail/promise_env.hpp +++ b/include/beman/task/detail/promise_env.hpp @@ -14,12 +14,12 @@ template struct promise_env { const Promise* promise; - auto query(const ::beman::execution::get_allocator_t&) const noexcept -> typename Promise::allocator_type { - return this->promise->get_allocator(); - } auto query(const ::beman::execution::get_scheduler_t&) const noexcept -> typename Promise::scheduler_type { return this->promise->get_scheduler(); } + auto query(const ::beman::execution::get_allocator_t&) const noexcept -> typename Promise::allocator_type { + return this->promise->get_allocator(); + } auto query(const ::beman::execution::get_stop_token_t&) const noexcept -> typename Promise::stop_token_type { return this->promise->get_stop_token(); } diff --git a/include/beman/task/detail/promise_type.hpp b/include/beman/task/detail/promise_type.hpp index 75bdce5..987e22f 100644 --- a/include/beman/task/detail/promise_type.hpp +++ b/include/beman/task/detail/promise_type.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/include/beman/task/detail/task.hpp b/include/beman/task/detail/task.hpp index 5d23b7d..22510be 100644 --- a/include/beman/task/detail/task.hpp +++ b/include/beman/task/detail/task.hpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/include/beman/task/task.hpp b/include/beman/task/task.hpp index 262d327..60d134d 100644 --- a/include/beman/task/task.hpp +++ b/include/beman/task/task.hpp @@ -4,9 +4,9 @@ #ifndef INCLUDED_INCLUDE_BEMAN_TASK_TASK #define INCLUDED_INCLUDE_BEMAN_TASK_TASK +#include #include #include -#include #include #include #include @@ -23,7 +23,7 @@ template using stop_source_of_t = ::beman::task::detail::stop_source_of_t; using task_scheduler = ::beman::task::detail::task_scheduler; -using inline_scheduler = ::beman::task::detail::inline_scheduler; +using inline_scheduler = ::beman::execution::inline_scheduler; using into_optional_t = ::beman::task::detail::into_optional_t; using ::beman::task::detail::into_optional; @@ -39,9 +39,8 @@ using scheduler_of_t = ::beman::task::detail::scheduler_of_t; template using stop_source_of_t = ::beman::task::detail::stop_source_of_t; -using task_scheduler = ::beman::task::detail::task_scheduler; -using inline_scheduler = ::beman::task::detail::inline_scheduler; -using into_optional_t = ::beman::task::detail::into_optional_t; +using task_scheduler = ::beman::task::detail::task_scheduler; +using into_optional_t = ::beman::task::detail::into_optional_t; using ::beman::task::detail::into_optional; using ::beman::task::detail::change_coroutine_scheduler; diff --git a/src/beman/task/CMakeLists.txt b/src/beman/task/CMakeLists.txt index 654ee1a..bbd5f89 100644 --- a/src/beman/task/CMakeLists.txt +++ b/src/beman/task/CMakeLists.txt @@ -25,7 +25,6 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/task/detail/final_awaiter.hpp ${PROJECT_SOURCE_DIR}/include/beman/task/detail/find_allocator.hpp ${PROJECT_SOURCE_DIR}/include/beman/task/detail/handle.hpp - ${PROJECT_SOURCE_DIR}/include/beman/task/detail/inline_scheduler.hpp ${PROJECT_SOURCE_DIR}/include/beman/task/detail/into_optional.hpp ${PROJECT_SOURCE_DIR}/include/beman/task/detail/logger.hpp ${PROJECT_SOURCE_DIR}/include/beman/task/detail/poly.hpp diff --git a/tests/beman/task/CMakeLists.txt b/tests/beman/task/CMakeLists.txt index 6a8b509..d989c0e 100644 --- a/tests/beman/task/CMakeLists.txt +++ b/tests/beman/task/CMakeLists.txt @@ -8,7 +8,6 @@ set(task_tests final_awaiter find_allocator handle - inline_scheduler lazy poly promise_base diff --git a/tests/beman/task/inline_scheduler.test.cpp b/tests/beman/task/inline_scheduler.test.cpp deleted file mode 100644 index 29c1b6a..0000000 --- a/tests/beman/task/inline_scheduler.test.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// tests/beman/task/inline_scheduler.test.cpp -*-C++-*- -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include -#include -#ifdef NDEBUG -#undef NDEBUG -#endif -#include - -namespace ex = beman::execution; -namespace ly = beman::task; - -// ---------------------------------------------------------------------------- - -namespace { -struct receiver { - using receiver_concept = ex::receiver_t; - int& value; - - void set_value(int v) && noexcept { this->value = v; } -}; -static_assert(ex::receiver); -} // namespace - -int main() { - ly::detail::inline_scheduler sched; - static_assert(ex::scheduler); - - auto sched_sender{ex::schedule(sched)}; - static_assert(ex::sender); - - auto env{ex::get_env(sched_sender)}; - assert(sched == ex::get_completion_scheduler(env)); - - int value{}; - auto state{ex::connect(sched_sender | ex::then([]() noexcept { return 17; }), receiver{value})}; - static_assert(ex::operation_state); - - assert(value == 0); - ex::start(state); - assert(value == 17); -} diff --git a/tests/beman/task/promise_base.test.cpp b/tests/beman/task/promise_base.test.cpp index 7e4e00b..adfe41d 100644 --- a/tests/beman/task/promise_base.test.cpp +++ b/tests/beman/task/promise_base.test.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #ifdef NDEBUG @@ -73,8 +72,8 @@ struct state : bt::state_base> { this->got_environment = true; return this->ev; } - auto do_get_scheduler() -> scheduler_type override { return scheduler_type(bt::inline_scheduler()); } - auto do_set_scheduler(scheduler_type) -> scheduler_type override { return scheduler_type(bt::inline_scheduler()); } + auto do_get_scheduler() -> scheduler_type override { return scheduler_type(ex::inline_scheduler()); } + auto do_set_scheduler(scheduler_type) -> scheduler_type override { return scheduler_type(ex::inline_scheduler()); } }; template diff --git a/tests/beman/task/promise_type.test.cpp b/tests/beman/task/promise_type.test.cpp index eb8dc86..0613b11 100644 --- a/tests/beman/task/promise_type.test.cpp +++ b/tests/beman/task/promise_type.test.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #ifdef NDEBUG #undef NDEBUG @@ -158,10 +157,10 @@ struct test_task : beman::task::detail::state_base { allocator_type do_get_allocator() override { return allocator_type{}; } stop_token_type do_get_stop_token() override { return this->source.get_token(); } environment& do_get_environment() override { return this->env; } - auto do_get_scheduler() -> scheduler_type override { return scheduler_type(bt::inline_scheduler()); } - auto do_set_scheduler(scheduler_type) -> scheduler_type override { return scheduler_type(bt::inline_scheduler()); } + auto do_get_scheduler() -> scheduler_type override { return scheduler_type(ex::inline_scheduler()); } + auto do_set_scheduler(scheduler_type) -> scheduler_type override { return scheduler_type(ex::inline_scheduler()); } - beman::task::detail::task_scheduler scheduler{beman::task::detail::inline_scheduler{}}; + beman::task::detail::task_scheduler scheduler{beman::execution::inline_scheduler{}}; beman::task::detail::task_scheduler query(beman::execution::get_scheduler_t) const noexcept { return this->scheduler; } diff --git a/tests/beman/task/scheduler_of.test.cpp b/tests/beman/task/scheduler_of.test.cpp index 5f91b08..d6faa47 100644 --- a/tests/beman/task/scheduler_of.test.cpp +++ b/tests/beman/task/scheduler_of.test.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #ifdef NDEBUG #undef NDEBUG @@ -16,7 +15,7 @@ namespace { struct no_scheduler {}; struct defines_scheduler { - using scheduler_type = beman::task::detail::inline_scheduler; + using scheduler_type = beman::execution::inline_scheduler; }; struct non_scheduler {}; @@ -29,6 +28,6 @@ int main() { static_assert( std::same_as>); static_assert( - std::same_as>); + std::same_as>); // using type = beman::task::detail::scheduler_of_t; } diff --git a/tests/beman/task/state_base.test.cpp b/tests/beman/task/state_base.test.cpp index 5f24109..8ad026c 100644 --- a/tests/beman/task/state_base.test.cpp +++ b/tests/beman/task/state_base.test.cpp @@ -1,14 +1,15 @@ // tests/beman/task/state_base.test.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include #include -#include #include #ifdef NDEBUG #undef NDEBUG #endif #include +namespace ex = beman::execution; namespace bt = beman::task::detail; // ---------------------------------------------------------------------------- @@ -37,8 +38,8 @@ struct state : beman::task::detail::state_base { this->got_environment = true; return this->env; } - auto do_get_scheduler() -> scheduler_type override { return scheduler_type(bt::inline_scheduler()); } - auto do_set_scheduler(scheduler_type) -> scheduler_type override { return scheduler_type(bt::inline_scheduler()); } + auto do_get_scheduler() -> scheduler_type override { return scheduler_type(ex::inline_scheduler()); } + auto do_set_scheduler(scheduler_type) -> scheduler_type override { return scheduler_type(ex::inline_scheduler()); } }; } // namespace diff --git a/tests/beman/task/task_scheduler.test.cpp b/tests/beman/task/task_scheduler.test.cpp index d5008a3..e1e3c6c 100644 --- a/tests/beman/task/task_scheduler.test.cpp +++ b/tests/beman/task/task_scheduler.test.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include -#include #include #include #include