Skip to content

Commit

Permalink
Merge pull request #796 from msimberg/fix-latch-ensure-started-test
Browse files Browse the repository at this point in the history
Fix lifetime issue with latch in `ensure_started` test
  • Loading branch information
msimberg authored Oct 4, 2023
2 parents 6c83143 + 950c4fb commit 50ca83b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libs/pika/execution/tests/unit/algorithm_ensure_started.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <atomic>
#include <exception>
#include <memory>
#include <stdexcept>
#include <string>
#include <type_traits>
Expand Down Expand Up @@ -173,11 +174,11 @@ int main()
// If the released shared state is accessed after it's released this test will fail under
// valgrind (e.g. while resetting the continuation right after invoking it).
{
pika::latch l(2);
auto l = std::make_shared<pika::latch>(2);
auto s = ex::schedule(ex::std_thread_scheduler{}) |
ex::then([&]() { l.arrive_and_wait(); }) | ex::ensure_started();
ex::then([l]() { l->arrive_and_wait(); }) | ex::ensure_started();
ex::start_detached(std::move(s));
l.arrive_and_wait();
l->arrive_and_wait();
}

// It's allowed to discard the sender from ensure_started
Expand Down

0 comments on commit 50ca83b

Please sign in to comment.