Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Disable extended warnings when debug is set to false.
[simgrid.git] / include / simgrid / simix / blocking_simcall.hpp
index c89b273..f7f233c 100644 (file)
@@ -71,6 +71,11 @@ auto kernelSync(F code) -> decltype(code().get())
 }
 
 /** A blocking (`wait()`-based) future for SIMIX processes */
+// TODO, .wait_for()
+// TODO, .wait_until()
+// TODO, SharedFuture
+// TODO, simgrid::simix::when_all - wait for all future to be ready (this one is simple!)
+// TODO, simgrid::simix::when_any - wait for any future to be ready
 template <class T>
 class Future {
 public:
@@ -108,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]{
@@ -127,8 +134,6 @@ public:
       }
     });
   }
-  // TODO, wait_for()
-  // TODO, wait_until()
 private:
   // We wrap an event-based kernel future:
   simgrid::kernel::Future<T> future_;