Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define getter/setter for Exception::value.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 23 Feb 2021 13:43:18 +0000 (14:43 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 23 Feb 2021 14:33:10 +0000 (15:33 +0100)
include/simgrid/Exception.hpp
src/kernel/activity/CommImpl.cpp
src/msg/msg_comm.cpp

index 613c527..5439656 100644 (file)
@@ -92,6 +92,10 @@ public:
   /** Return the information about where the exception was thrown */
   xbt::ThrowPoint const& throw_point() const { return throwpoint_; }
 
+  /** Allow to carry a value (used by testany/waitany) */
+  int get_value() const { return value_; }
+  void set_value(int value) { value_ = value; }
+
   std::string resolve_backtrace() const { return throwpoint_.backtrace_.resolve(); }
 
   virtual void rethrow_nested(const simgrid::xbt::ThrowPoint& throwpoint, const std::string& message) const
@@ -99,11 +103,9 @@ public:
     std::throw_with_nested(Exception(throwpoint, message));
   }
 
-  /** Allow to carry a value (used by waitall/waitany) */
-  int value = 0;
-
 private:
   xbt::ThrowPoint throwpoint_;
+  int value_ = 0;
 };
 
 #define DECLARE_SIMGRID_EXCEPTION(AnyException, ...)                                                                   \
index cf007f6..15ceed9 100644 (file)
@@ -686,12 +686,11 @@ void CommImpl::finish()
       }
       CommImpl** element = std::find(comms, comms + count, this);
       int rank           = (element != comms + count) ? element - comms : -1;
-
       // In order to modify the exception we have to rethrow it:
       try {
         std::rethrow_exception(simcall->issuer_->exception_);
       } catch (simgrid::Exception& e) {
-        e.value = rank;
+        e.set_value(rank);
       }
     }
 
index 3a4bca2..fd36e6e 100644 (file)
@@ -99,13 +99,13 @@ int MSG_comm_testany(const_xbt_dynar_t comms)
   try {
     finished_index = simcall_comm_testany(s_comms.data(), s_comms.size());
   } catch (const simgrid::TimeoutException& e) {
-    finished_index = e.value;
+    finished_index = e.get_value();
     status         = MSG_TIMEOUT;
   } catch (const simgrid::CancelException& e) {
-    finished_index = e.value;
+    finished_index = e.get_value();
     status         = MSG_TASK_CANCELED;
   } catch (const simgrid::NetworkFailureException& e) {
-    finished_index = e.value;
+    finished_index = e.get_value();
     status         = MSG_TRANSFER_FAILURE;
   }
 
@@ -176,13 +176,13 @@ int MSG_comm_waitany(const_xbt_dynar_t comms)
   try {
     finished_index = simcall_comm_waitany(s_comms.data(), s_comms.size(), -1);
   } catch (const simgrid::TimeoutException& e) {
-    finished_index = e.value;
+    finished_index = e.get_value();
     status         = MSG_TIMEOUT;
   } catch (const simgrid::CancelException& e) {
-    finished_index = e.value;
+    finished_index = e.get_value();
     status         = MSG_TASK_CANCELED;
   } catch (const simgrid::NetworkFailureException& e) {
-    finished_index = e.value;
+    finished_index = e.get_value();
     status         = MSG_TRANSFER_FAILURE;
   }