diff --git a/src/io/future.hpp b/src/io/future.hpp index ddfde4723..da0cbb81f 100644 --- a/src/io/future.hpp +++ b/src/io/future.hpp @@ -182,7 +182,7 @@ class Future { /// Block on the corresponding promise to be filled, /// returning the inner item when ready. - T Wait() { + T Wait() && { MG_ASSERT(!consumed_or_moved_, "Future should only be consumed with Wait once!"); T ret = shared_->Wait(); consumed_or_moved_ = true; diff --git a/tests/simulation/basic_request.cpp b/tests/simulation/basic_request.cpp index 0a01c1703..6e87b8e41 100644 --- a/tests/simulation/basic_request.cpp +++ b/tests/simulation/basic_request.cpp @@ -72,7 +72,7 @@ int main() { CounterRequest cli_req; cli_req.proposal = i; auto res_f = cli_io.Request(srv_addr, cli_req); - auto res_rez = res_f.Wait(); + auto res_rez = std::move(res_f).Wait(); if (!res_rez.HasError()) { std::cout << "[CLIENT] Got a valid response" << std::endl; auto env = res_rez.GetValue(); diff --git a/tests/simulation/future.cpp b/tests/simulation/future.cpp index 94d3154c0..861769ea5 100644 --- a/tests/simulation/future.cpp +++ b/tests/simulation/future.cpp @@ -20,7 +20,7 @@ using namespace memgraph::io; void Fill(Promise promise_1) { promise_1.Fill("success"); } void Wait(Future future_1, Promise promise_2) { - std::string result_1 = future_1.Wait(); + std::string result_1 = std::move(future_1).Wait(); MG_ASSERT(result_1 == "success"); promise_2.Fill("it worked"); } @@ -49,7 +49,7 @@ int main() { t1.join(); t2.join(); - std::string result_2 = future_2.Wait(); + std::string result_2 = std::move(future_2).Wait(); MG_ASSERT(result_2 == "it worked"); return 0; diff --git a/tests/simulation/trial_query_storage/query_storage_test.cpp b/tests/simulation/trial_query_storage/query_storage_test.cpp index 91d8f5fa7..79c11da60 100644 --- a/tests/simulation/trial_query_storage/query_storage_test.cpp +++ b/tests/simulation/trial_query_storage/query_storage_test.cpp @@ -79,7 +79,7 @@ int main() { auto req = ScanVerticesRequest{2, std::nullopt}; auto res_f = cli_io.Request(srv_addr, req); - auto res_rez = res_f.Wait(); + auto res_rez = std::move(res_f).Wait(); // MG_ASSERT(res_rez.HasError()); simulator.ShutDown(); return 0;