From 738a31e2e7bd7c64f154cedbb2f330151be57788 Mon Sep 17 00:00:00 2001 From: Spencer T Brody Date: Fri, 17 Jul 2020 15:28:57 -0400 Subject: SERVER-49702 Add way to explicitly fork SharedSemiFuture continuation chain --- src/mongo/util/future_test_shared_future.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/mongo/util/future_test_shared_future.cpp') diff --git a/src/mongo/util/future_test_shared_future.cpp b/src/mongo/util/future_test_shared_future.cpp index 1a17fd994c1..e2740860d2e 100644 --- a/src/mongo/util/future_test_shared_future.cpp +++ b/src/mongo/util/future_test_shared_future.cpp @@ -239,7 +239,7 @@ TEST(SharedFuture, ThenChaining_Async_DoubleShare) { }); } -TEST(SharedFuture, AddChild_Get) { +TEST(SharedFuture, AddChild_ThenRunOn_Get) { FUTURE_SUCCESS_TEST([] {}, [](/*Future*/ auto&& fut) { const auto exec = InlineCountingExecutor::make(); @@ -250,6 +250,16 @@ TEST(SharedFuture, AddChild_Get) { }); } +TEST(SharedFuture, AddChild_Split_Get) { + FUTURE_SUCCESS_TEST([] { return 1; }, + [](/*Future*/ auto&& fut) { + auto shared = std::move(fut).share(); + auto shared2 = shared.split(); + ASSERT_EQ(shared.get(), 1); + ASSERT_EQ(shared2.get(), 1); + }); +} + TEST(SharedFuture, InterruptedGet_AddChild_Get) { FUTURE_SUCCESS_TEST([] {}, [](/*Future*/ auto&& fut) { -- cgit v1.2.1