From edf9b2a92ea61289ebc6d5a9f50db778d6cddde7 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 25 Feb 2025 11:28:27 -0800 Subject: [PATCH] renames `start_on` and `continue_on` to `starts_on` and `continues_on` --- examples/scratch.cpp | 2 +- .../{continue_on.hpp => continues_on.hpp} | 2 +- .../detail/{start_on.hpp => starts_on.hpp} | 2 +- include/ustdex/ustdex.hpp | 4 +- tests/common/catch2.hpp | 4 +- ..._continue_on.cpp => test_continues_on.cpp} | 102 +++++++++--------- tests/test_when_all.cpp | 26 ++--- 7 files changed, 71 insertions(+), 71 deletions(-) rename include/ustdex/detail/{continue_on.hpp => continues_on.hpp} (99%) rename include/ustdex/detail/{start_on.hpp => starts_on.hpp} (99%) rename tests/{test_continue_on.cpp => test_continues_on.cpp} (61%) diff --git a/examples/scratch.cpp b/examples/scratch.cpp index 6397036..1b37566 100644 --- a/examples/scratch.cpp +++ b/examples/scratch.cpp @@ -60,7 +60,7 @@ int main() std::printf("%d %d %d\n", a, b, c); return a + b + c; }); - auto s = start_on(sch, std::move(work)); + auto s = starts_on(sch, std::move(work)); static_assert(!dependent_sender); std::puts("Hello, world!"); sync_wait(s); diff --git a/include/ustdex/detail/continue_on.hpp b/include/ustdex/detail/continues_on.hpp similarity index 99% rename from include/ustdex/detail/continue_on.hpp rename to include/ustdex/detail/continues_on.hpp index 848f5f4..e47c648 100644 --- a/include/ustdex/detail/continue_on.hpp +++ b/include/ustdex/detail/continues_on.hpp @@ -280,7 +280,7 @@ USTDEX_TRIVIAL_API continue_on_t::_closure_t continue_on_t::operator()(Sch return _closure_t{_sch}; } -inline constexpr continue_on_t continue_on{}; +inline constexpr continue_on_t continues_on{}; } // namespace ustdex #include "epilogue.hpp" diff --git a/include/ustdex/detail/start_on.hpp b/include/ustdex/detail/starts_on.hpp similarity index 99% rename from include/ustdex/detail/start_on.hpp rename to include/ustdex/detail/starts_on.hpp index fa9daec..d8dbb42 100644 --- a/include/ustdex/detail/start_on.hpp +++ b/include/ustdex/detail/starts_on.hpp @@ -94,7 +94,7 @@ inline constexpr struct start_on_t template USTDEX_API auto operator()(Sch _sch, Sndr _sndr) const noexcept // -> _sndr_t; -} start_on{}; +} starts_on{}; template struct USTDEX_TYPE_VISIBILITY_DEFAULT start_on_t::_sndr_t diff --git a/include/ustdex/ustdex.hpp b/include/ustdex/ustdex.hpp index cf8df28..482bbdc 100644 --- a/include/ustdex/ustdex.hpp +++ b/include/ustdex/ustdex.hpp @@ -18,7 +18,7 @@ #include "detail/conditional.hpp" #include "detail/config.hpp" -#include "detail/continue_on.hpp" +#include "detail/continues_on.hpp" #include "detail/cpos.hpp" #include "detail/just.hpp" #include "detail/just_from.hpp" @@ -28,7 +28,7 @@ #include "detail/run_loop.hpp" #include "detail/sequence.hpp" #include "detail/start_detached.hpp" -#include "detail/start_on.hpp" +#include "detail/starts_on.hpp" #include "detail/stop_token.hpp" #include "detail/sync_wait.hpp" #include "detail/then.hpp" diff --git a/tests/common/catch2.hpp b/tests/common/catch2.hpp index 21158d5..9f80b8f 100644 --- a/tests/common/catch2.hpp +++ b/tests/common/catch2.hpp @@ -17,14 +17,14 @@ #pragma once -#include "ustdex/ustdex.hpp" +#include "ustdex/ustdex.hpp" // IWYU pragma: export #if !USTDEX_HOST_ONLY() // disable exceptions in Catch2 when compiling for device: # define CATCH_CONFIG_DISABLE_EXCEPTIONS #endif -#include +#include // IWYU pragma: export // In device code, a few of the Catch2 macros are not supported. #if !USTDEX_HOST_ONLY() diff --git a/tests/test_continue_on.cpp b/tests/test_continues_on.cpp similarity index 61% rename from tests/test_continue_on.cpp rename to tests/test_continues_on.cpp index 7afb2b2..0ccd732 100644 --- a/tests/test_continue_on.cpp +++ b/tests/test_continues_on.cpp @@ -33,33 +33,33 @@ namespace ex = ustdex; namespace { -// TEST_CASE("continue_on returns a sender", "[adaptors][continue_on]") { -// auto snd = ex::continue_on(ex::just(13), inline_scheduler{}); -// static_assert(ex::sender); -// (void) snd; -// } +TEST_CASE("continues_on returns a sender", "[adaptors][continues_on]") { + auto snd = ex::continues_on(ex::just(13), inline_scheduler{}); + static_assert(ex::sender); + (void) snd; +} -// TEST_CASE("continue_on with environment returns a sender", "[adaptors][continue_on]") { -// auto snd = ex::continue_on(ex::just(13), inline_scheduler{}); -// static_assert(ex::sender_in>); -// (void) snd; -// } +TEST_CASE("continues_on with environment returns a sender", "[adaptors][continues_on]") { + auto snd = ex::continues_on(ex::just(13), inline_scheduler{}); + static_assert(ex::sender_in>); + (void) snd; +} -TEST_CASE("continue_on simple example", "[adaptors][continue_on]") +TEST_CASE("continues_on simple example", "[adaptors][continues_on]") { - auto snd = ex::continue_on(ex::just(13), inline_scheduler{}); + auto snd = ex::continues_on(ex::just(13), inline_scheduler{}); auto op = ex::connect(std::move(snd), checked_value_receiver{13}); ex::start(op); // The receiver checks if we receive the right value } -TEST_CASE("continue_on can be piped", "[adaptors][continue_on]") +TEST_CASE("continues_on can be piped", "[adaptors][continues_on]") { - // Just continue_on a value to the impulse scheduler + // Just continues_on a value to the impulse scheduler bool called{false}; auto sched = impulse_scheduler{}; auto snd = ex::just(13) // - | ex::continue_on(sched) // + | ex::continues_on(sched) // | ex::then([&](int val) { called = true; return val; @@ -74,11 +74,11 @@ TEST_CASE("continue_on can be piped", "[adaptors][continue_on]") REQUIRE(called); } -TEST_CASE("continue_on calls the receiver when the scheduler dictates", "[adaptors][continue_on]") +TEST_CASE("continues_on calls the receiver when the scheduler dictates", "[adaptors][continues_on]") { bool called{false}; impulse_scheduler sched; - auto snd = ex::then(ex::continue_on(ex::just(13), sched), [&](int val) { + auto snd = ex::then(ex::continues_on(ex::just(13), sched), [&](int val) { called = true; return val; }); @@ -92,7 +92,7 @@ TEST_CASE("continue_on calls the receiver when the scheduler dictates", "[adapto CHECK(called); } -TEST_CASE("continue_on calls the given sender when the scheduler dictates", "[adaptors][continue_on]") +TEST_CASE("continues_on calls the given sender when the scheduler dictates", "[adaptors][continues_on]") { int counter{0}; auto snd_base = ex::just() // @@ -102,7 +102,7 @@ TEST_CASE("continue_on calls the given sender when the scheduler dictates", "[ad }); impulse_scheduler sched; - auto snd = ex::then(ex::continue_on(std::move(snd_base), sched), [&](int val) { + auto snd = ex::then(ex::continues_on(std::move(snd_base), sched), [&](int val) { ++counter; return val; }); @@ -119,14 +119,14 @@ TEST_CASE("continue_on calls the given sender when the scheduler dictates", "[ad CHECK(counter == 2); } -TEST_CASE("continue_on works when changing threads", "[adaptors][continue_on]") +TEST_CASE("continues_on works when changing threads", "[adaptors][continues_on]") { ex::thread_context thread; bool called{false}; { // lunch some work on the thread pool - auto snd = ex::continue_on(ex::just(), thread.get_scheduler()) // + auto snd = ex::continues_on(ex::just(), thread.get_scheduler()) // | ex::then([&] { called = true; }); @@ -139,97 +139,97 @@ TEST_CASE("continue_on works when changing threads", "[adaptors][continue_on]") REQUIRE(called); } -TEST_CASE("continue_on can be called with rvalue ref scheduler", "[adaptors][continue_on]") +TEST_CASE("continues_on can be called with rvalue ref scheduler", "[adaptors][continues_on]") { - auto snd = ex::continue_on(ex::just(13), inline_scheduler{}); + auto snd = ex::continues_on(ex::just(13), inline_scheduler{}); auto op = ex::connect(std::move(snd), checked_value_receiver{13}); ex::start(op); // The receiver checks if we receive the right value } -TEST_CASE("continue_on can be called with const ref scheduler", "[adaptors][continue_on]") +TEST_CASE("continues_on can be called with const ref scheduler", "[adaptors][continues_on]") { const inline_scheduler sched; - auto snd = ex::continue_on(ex::just(13), sched); + auto snd = ex::continues_on(ex::just(13), sched); auto op = ex::connect(std::move(snd), checked_value_receiver{13}); ex::start(op); // The receiver checks if we receive the right value } -TEST_CASE("continue_on can be called with ref scheduler", "[adaptors][continue_on]") +TEST_CASE("continues_on can be called with ref scheduler", "[adaptors][continues_on]") { inline_scheduler sched; - auto snd = ex::continue_on(ex::just(13), sched); + auto snd = ex::continues_on(ex::just(13), sched); auto op = ex::connect(std::move(snd), checked_value_receiver{13}); ex::start(op); // The receiver checks if we receive the right value } -TEST_CASE("continue_on forwards set_error calls", "[adaptors][continue_on]") +TEST_CASE("continues_on forwards set_error calls", "[adaptors][continues_on]") { auto eptr = std::make_exception_ptr(std::runtime_error{"error"}); error_scheduler sched{eptr}; - auto snd = ex::continue_on(ex::just(13), sched); + auto snd = ex::continues_on(ex::just(13), sched); auto op = ex::connect(std::move(snd), checked_error_receiver{eptr}); ex::start(op); // The receiver checks if we receive an error } -TEST_CASE("continue_on forwards set_error calls of other types", "[adaptors][continue_on]") +TEST_CASE("continues_on forwards set_error calls of other types", "[adaptors][continues_on]") { error_scheduler sched{std::string{"error"}}; - auto snd = ex::continue_on(ex::just(13), sched); + auto snd = ex::continues_on(ex::just(13), sched); auto op = ex::connect(std::move(snd), checked_error_receiver{std::string{"error"}}); ex::start(op); // The receiver checks if we receive an error } -TEST_CASE("continue_on forwards set_stopped calls", "[adaptors][continue_on]") +TEST_CASE("continues_on forwards set_stopped calls", "[adaptors][continues_on]") { stopped_scheduler sched{}; - auto snd = ex::continue_on(ex::just(13), sched); + auto snd = ex::continues_on(ex::just(13), sched); auto op = ex::connect(std::move(snd), checked_stopped_receiver{}); ex::start(op); // The receiver checks if we receive the stopped signal } -TEST_CASE("continue_on has the values_type corresponding to the given values", "[adaptors][continue_on]") +TEST_CASE("continues_on has the values_type corresponding to the given values", "[adaptors][continues_on]") { inline_scheduler sched{}; - check_value_types<_m_list>(ex::continue_on(ex::just(1), sched)); - check_value_types<_m_list>(ex::continue_on(ex::just(3, 0.14), sched)); - check_value_types<_m_list>(ex::continue_on(ex::just(3, 0.14, std::string{"pi"}), sched)); + check_value_types<_m_list>(ex::continues_on(ex::just(1), sched)); + check_value_types<_m_list>(ex::continues_on(ex::just(3, 0.14), sched)); + check_value_types<_m_list>(ex::continues_on(ex::just(3, 0.14, std::string{"pi"}), sched)); } -TEST_CASE("continue_on keeps error_types from scheduler's sender", "[adaptors][continue_on]") +TEST_CASE("continues_on keeps error_types from scheduler's sender", "[adaptors][continues_on]") { inline_scheduler sched1{}; error_scheduler sched2{std::make_exception_ptr(std::runtime_error{"error"})}; error_scheduler sched3{43}; - check_error_types<>(ex::continue_on(ex::just(1), sched1)); - check_error_types(ex::continue_on(ex::just(2), sched2)); - check_error_types(ex::continue_on(ex::just(3), sched3)); + check_error_types<>(ex::continues_on(ex::just(1), sched1)); + check_error_types(ex::continues_on(ex::just(2), sched2)); + check_error_types(ex::continues_on(ex::just(3), sched3)); } -TEST_CASE("continue_on sends an exception_ptr if value types are potentially throwing when copied", - "[adaptors][continue_on]") +TEST_CASE("continues_on sends an exception_ptr if value types are potentially throwing when copied", + "[adaptors][continues_on]") { inline_scheduler sched{}; - check_error_types(ex::continue_on(ex::just(potentially_throwing{}), sched)); + check_error_types(ex::continues_on(ex::just(potentially_throwing{}), sched)); } -TEST_CASE("continue_on keeps sends_stopped from scheduler's sender", "[adaptors][continue_on]") +TEST_CASE("continues_on keeps sends_stopped from scheduler's sender", "[adaptors][continues_on]") { inline_scheduler sched1{}; error_scheduler sched2{std::make_exception_ptr(std::runtime_error{"error"})}; stopped_scheduler sched3{}; - check_sends_stopped(ex::continue_on(ex::just(1), sched1)); - check_sends_stopped(ex::continue_on(ex::just(2), sched2)); - check_sends_stopped(ex::continue_on(ex::just(3), sched3)); + check_sends_stopped(ex::continues_on(ex::just(1), sched1)); + check_sends_stopped(ex::continues_on(ex::just(2), sched2)); + check_sends_stopped(ex::continues_on(ex::just(3), sched3)); } // struct test_domain_A { @@ -247,12 +247,12 @@ TEST_CASE("continue_on keeps sends_stopped from scheduler's sender", "[adaptors] // }; // TEST_CASE( -// "continue_on late customization is passed on the destination scheduler", -// "[adaptors][continue_on]") { +// "continues_on late customization is passed on the destination scheduler", +// "[adaptors][continues_on]") { // // The customization will return a different value // ex::scheduler auto sched_A = basic_inline_scheduler{}; // ex::scheduler auto sched_B = basic_inline_scheduler{}; -// auto snd = ex::on(sched_A, ex::just() | ex::continue_on(sched_B)); +// auto snd = ex::on(sched_A, ex::just() | ex::continues_on(sched_B)); // std::string res; // auto op = ex::connect(std::move(snd), expect_value_receiver_ex{res}); // ex::start(op); diff --git a/tests/test_when_all.cpp b/tests/test_when_all.cpp index ef0543b..521569b 100644 --- a/tests/test_when_all.cpp +++ b/tests/test_when_all.cpp @@ -20,10 +20,10 @@ #include "../tests/common/impulse_scheduler.hpp" #include "../tests/common/stopped_scheduler.hpp" #include "../tests/common/utility.hpp" -#include "ustdex/detail/continue_on.hpp" +#include "ustdex/detail/continues_on.hpp" #include "ustdex/detail/just.hpp" #include "ustdex/detail/let_value.hpp" -#include "ustdex/detail/start_on.hpp" +#include "ustdex/detail/starts_on.hpp" #include "ustdex/detail/then.hpp" #include "ustdex/detail/when_all.hpp" #include @@ -82,9 +82,9 @@ TEST_CASE("when_all completes when children complete", "[when_all]") { impulse_scheduler sched; bool called{false}; - auto snd = ex::when_all(ex::just(11) | ex::continue_on(sched), - ex::just(13) | ex::continue_on(sched), - ex::just(17) | ex::continue_on(sched)) + auto snd = ex::when_all(ex::just(11) | ex::continues_on(sched), + ex::just(13) | ex::continues_on(sched), + ex::just(17) | ex::continues_on(sched)) | ex::then([&](int a, int b, int c) { called = true; return a + b + c; @@ -111,7 +111,7 @@ TEST_CASE("when_all can be used with just_*", "[when_all]") TEST_CASE("when_all terminates with error if one child terminates with error", "[when_all]") { error_scheduler sched{42}; - auto snd = ex::when_all(ex::just(2), ex::just(5) | ex::continue_on(sched), ex::just(7)); + auto snd = ex::when_all(ex::just(2), ex::just(5) | ex::continues_on(sched), ex::just(7)); auto op = ex::connect(std::move(snd), checked_error_receiver{42}); ex::start(op); } @@ -119,7 +119,7 @@ TEST_CASE("when_all terminates with error if one child terminates with error", " TEST_CASE("when_all terminates with stopped if one child is cancelled", "[when_all]") { stopped_scheduler sched; - auto snd = ex::when_all(ex::just(2), ex::just(5) | ex::continue_on(sched), ex::just(7)); + auto snd = ex::when_all(ex::just(2), ex::just(5) | ex::continues_on(sched), ex::just(7)); auto op = ex::connect(std::move(snd), checked_stopped_receiver{}); ex::start(op); } @@ -132,11 +132,11 @@ TEST_CASE("when_all cancels remaining children if error is detected", "[when_all bool called3{false}; bool cancelled{false}; auto snd = ex::when_all( - ex::start_on(sched, ex::just()) | ex::then([&] { + ex::starts_on(sched, ex::just()) | ex::then([&] { called1 = true; }), - ex::start_on(sched, ex::just(5) | ex::continue_on(err_sched)), - ex::start_on(sched, ex::just()) | ex::then([&] { + ex::starts_on(sched, ex::just(5) | ex::continues_on(err_sched)), + ex::starts_on(sched, ex::just()) | ex::then([&] { called3 = true; }) | ex::let_stopped([&] { cancelled = true; @@ -164,11 +164,11 @@ TEST_CASE("when_all cancels remaining children if cancel is detected", "[when_al bool called3{false}; bool cancelled{false}; auto snd = ex::when_all( - ex::start_on(sched, ex::just()) | ex::then([&] { + ex::starts_on(sched, ex::just()) | ex::then([&] { called1 = true; }), - ex::start_on(sched, ex::just(5) | ex::continue_on(stopped_sched)), - ex::start_on(sched, ex::just()) | ex::then([&] { + ex::starts_on(sched, ex::just(5) | ex::continues_on(stopped_sched)), + ex::starts_on(sched, ex::just()) | ex::then([&] { called3 = true; }) | ex::let_stopped([&] { cancelled = true;