Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Make Mutex a C++ class (kind-of)
[simgrid.git] / include / xbt / future.hpp
index d583c34..81c8845 100644 (file)
@@ -73,13 +73,13 @@ public:
     return *this;
   }
 
-  bool is_valid()
+  bool is_valid() const
   {
     return status_ != ResultStatus::invalid;
   }
   void reset()
   {
-    switch(status_) {
+    switch (status_) {
       case ResultStatus::invalid:
         break;
       case ResultStatus::value:
@@ -116,7 +116,7 @@ public:
    **/
   T get()
   {
-    switch(status_) {
+    switch (status_) {
       case ResultStatus::invalid:
       default:
         throw std::logic_error("Invalid result");
@@ -144,7 +144,7 @@ private:
 };
 
 template<>
-class Result<void> : public Result<nullptr_t>
+class Result<void> : public Result<std::nullptr_t>
 {
 public:
   void set_value()
@@ -153,7 +153,7 @@ public:
   }
   void get()
   {
-    Result<nullptr_t>::get();
+    Result<std::nullptr_t>::get();
   }
 };
 
@@ -171,7 +171,14 @@ public:
   }
 };
 
-/** Fulfill a promise by executing a given code */
+/** Execute some code and set a promise or result accordingly
+ *
+ *  We might need this when working with generic code because
+ *  the trivial implementation does not work with void (before C++1z).
+ *
+ *  @param    code  What we want to do
+ *  @param  promise Where to want to store the result
+ */
 template<class R, class F>
 auto fulfillPromise(R& promise, F&& code)
 -> decltype(promise.set_value(code()))
@@ -184,11 +191,6 @@ auto fulfillPromise(R& promise, F&& code)
   }
 }
 
-/** Fulfill a promise by executing a given code
- *
- *  This is a special version for `std::promise<void>` because the default
- *  version does not compile in this case.
- */
 template<class P, class F>
 auto fulfillPromise(P& promise, F&& code)
 -> decltype(promise.set_value())