aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/coro/lazy
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2022-11-08 10:56:02 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2022-11-08 10:56:02 +0000
commitc3c218051eb9b8f75c23db3ca6bad06e9cd3314a (patch)
tree68f74d19d5ab807fae5187fda5c3889fa4e800cf /vespalib/src/tests/coro/lazy
parentd29cb7e64a30a93b4ab445c872449809cdde6bcd (diff)
return value forwarding for Lazy<T>
Diffstat (limited to 'vespalib/src/tests/coro/lazy')
-rw-r--r--vespalib/src/tests/coro/lazy/lazy_test.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/vespalib/src/tests/coro/lazy/lazy_test.cpp b/vespalib/src/tests/coro/lazy/lazy_test.cpp
index ec27bf195ec..29aac4440fc 100644
--- a/vespalib/src/tests/coro/lazy/lazy_test.cpp
+++ b/vespalib/src/tests/coro/lazy/lazy_test.cpp
@@ -168,4 +168,25 @@ TEST(LazyTest, async_wait_with_move_only_result) {
EXPECT_EQ(*(result.get_value()), 123);
}
+struct Refs {
+ Gate &gate;
+ Received<std::unique_ptr<int>> &result;
+ Refs(Gate &gate_in, Received<std::unique_ptr<int>> &result_in)
+ : gate(gate_in), result(result_in) {}
+};
+
+TEST(LazyTest, async_wait_with_move_only_result_and_move_only_lambda) {
+ Gate gate;
+ Received<std::unique_ptr<int>> result;
+ vespalib::ThreadStackExecutor executor(1, 128_Ki);
+ auto lazy = schedule_on(executor, move_only_int());
+ async_wait(std::move(lazy), [refs = std::make_unique<Refs>(gate,result)](auto res)
+ {
+ refs->result = std::move(res);
+ refs->gate.countDown();
+ });
+ gate.await();
+ EXPECT_EQ(*(result.get_value()), 123);
+}
+
GTEST_MAIN_RUN_ALL_TESTS()