Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Future::wait(), avoid simcall when we are ready
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 20 Jun 2016 14:01:34 +0000 (16:01 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Mon, 20 Jun 2016 14:06:30 +0000 (16:06 +0200)
include/simgrid/simix/blocking_simcall.hpp

index 2e26f0a..f7f233c 100644 (file)
@@ -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]{