Skip to content

Commit

Permalink
Merge #6341
Browse files Browse the repository at this point in the history
6341: Fix shared_future_continuation_order regression test r=hkaiser a=Pansysk75

Fixes occasional failure of shared_future_continuation_order regression test.
If my understanding is correct, continuations are executed on newly spawned threads by default, which would not guarantee their order of execution. Launching with hpx::launch::sync should guarantee that no new thread is spawned, thus they are executed in sequence.
(`@hkaiser` We had fixed this in some PR in the past, but it seems it didn't make it into master)

Co-authored-by: Panos Syskakis <[email protected]>
  • Loading branch information
StellarBot and Pansysk75 committed Sep 2, 2023
2 parents a6ed839 + 7170d7d commit 5457e19
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ int hpx_main()
hpx::promise<int> p;
hpx::shared_future<int> f1 = p.get_future();

hpx::future<int> f2 = f1.then([](hpx::shared_future<int>&& f) {
HPX_TEST_EQ(f.get(), 42);
return ++invocation_count;
});

hpx::future<int> f3 = f1.then([](hpx::shared_future<int>&& f) {
HPX_TEST_EQ(f.get(), 42);
return ++invocation_count;
});
hpx::future<int> f2 =
f1.then(hpx::launch::sync, [](hpx::shared_future<int>&& f) {
HPX_TEST_EQ(f.get(), 42);
return ++invocation_count;
});

hpx::future<int> f3 =
f1.then(hpx::launch::sync, [](hpx::shared_future<int>&& f) {
HPX_TEST_EQ(f.get(), 42);
return ++invocation_count;
});

p.set_value(42);

Expand Down

0 comments on commit 5457e19

Please sign in to comment.