Skip to content

Commit

Permalink
Merge pull request #433 from janondrusek/async-attach
Browse files Browse the repository at this point in the history
`async_scope::attach` cleanup
  • Loading branch information
AnujYamdagni authored Jul 7, 2022
2 parents bd2388e + 445df0e commit ebd6f9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/unifex/async_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ struct async_scope {
/**
* Equivalent to attach(just_from((Fun&&)fun)).
*/
template(typename Scheduler, typename Fun) //
template(typename Fun) //
(requires callable<Fun>) //
[[nodiscard]] auto attach_call(Fun&& fun) noexcept(
noexcept(attach(just_from((Fun &&) fun)))) {
Expand Down
13 changes: 13 additions & 0 deletions test/async_scope_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,19 @@ TEST_F(async_scope_test, attach) {
sync_wait(scope.cleanup());
}

TEST_F(async_scope_test, attach_connect) {
mock_receiver<void()> 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<void()> receiver;
EXPECT_CALL(*receiver, set_value()).Times(2);
Expand Down

0 comments on commit ebd6f9b

Please sign in to comment.