From 4d91fd9b32ef1b98394c922e8d8198e2485ba024 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Mon, 20 Jun 2016 16:01:34 +0200 Subject: [PATCH] [simix] Future::wait(), avoid simcall when we are ready --- include/simgrid/simix/blocking_simcall.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/simgrid/simix/blocking_simcall.hpp b/include/simgrid/simix/blocking_simcall.hpp index 2e26f0a2ba..f7f233c046 100644 --- a/include/simgrid/simix/blocking_simcall.hpp +++ b/include/simgrid/simix/blocking_simcall.hpp @@ -113,8 +113,10 @@ public: } void wait() { - if (!valid()) - throw std::future_error(std::future_errc::no_state); + // The future is ready! We don't have to wait: + if (this->is_ready()) + return; + // The future is not ready. We have to delegate to the SimGrid kernel: std::exception_ptr exception; smx_process_t self = SIMIX_process_self(); simcall_run_blocking([this, &exception, self]{ -- 2.30.2