Use rvalue reference requirement for Future::Wait
This commit is contained in:
parent
9056e2c97a
commit
6bdfb43ad0
src/io
tests/simulation
@ -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;
|
||||
|
@ -72,7 +72,7 @@ int main() {
|
||||
CounterRequest cli_req;
|
||||
cli_req.proposal = i;
|
||||
auto res_f = cli_io.Request<CounterRequest, CounterResponse>(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();
|
||||
|
@ -20,7 +20,7 @@ using namespace memgraph::io;
|
||||
void Fill(Promise<std::string> promise_1) { promise_1.Fill("success"); }
|
||||
|
||||
void Wait(Future<std::string> future_1, Promise<std::string> 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;
|
||||
|
@ -79,7 +79,7 @@ int main() {
|
||||
auto req = ScanVerticesRequest{2, std::nullopt};
|
||||
|
||||
auto res_f = cli_io.Request<ScanVerticesRequest, VerticesResponse>(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;
|
||||
|
Loading…
Reference in New Issue
Block a user