From 445df0e58d9c137afcc31832ec62f97d6a85a63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Ondru=C5=A1ek?= Date: Thu, 7 Jul 2022 12:35:10 -0700 Subject: [PATCH] `async_scope::attach` cleanup * remove unused template argument * add missing test case --- include/unifex/async_scope.hpp | 2 +- test/async_scope_test.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/unifex/async_scope.hpp b/include/unifex/async_scope.hpp index 241fe4534..f818ffacc 100644 --- a/include/unifex/async_scope.hpp +++ b/include/unifex/async_scope.hpp @@ -977,7 +977,7 @@ struct async_scope { /** * Equivalent to attach(just_from((Fun&&)fun)). */ - template(typename Scheduler, typename Fun) // + template(typename Fun) // (requires callable) // [[nodiscard]] auto attach_call(Fun&& fun) noexcept( noexcept(attach(just_from((Fun &&) fun)))) { diff --git a/test/async_scope_test.cpp b/test/async_scope_test.cpp index 81d7e68af..0bd5307cf 100644 --- a/test/async_scope_test.cpp +++ b/test/async_scope_test.cpp @@ -479,6 +479,19 @@ TEST_F(async_scope_test, attach) { sync_wait(scope.cleanup()); } +TEST_F(async_scope_test, attach_connect) { + mock_receiver receiver; + auto sender = scope.attach(just()); + + // the outstanding operation is "transferred" from sender to operation + { + auto op = connect(std::move(sender), receiver); + // the operation is dropped w/o starting + } + // this will hang if record done on async_scope doesn't happen + sync_wait(scope.cleanup()); +} + TEST_F(async_scope_test, attach_copy) { mock_receiver receiver; EXPECT_CALL(*receiver, set_value()).Times(2);