Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
week-end cleanups in ActorImpl
[simgrid.git] / src / simix / smx_network.cpp
index b855c9f..828235a 100644 (file)
@@ -227,7 +227,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_activity_t synchro, do
   if (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING) {
     SIMIX_comm_finish(synchro);
   } else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
-    simgrid::kernel::resource::Action* sleep = simcall->issuer->host_->pimpl_cpu->sleep(timeout);
+    simgrid::kernel::resource::Action* sleep = simcall->issuer->get_host()->pimpl_cpu->sleep(timeout);
     sleep->set_data(synchro.get());
 
     simgrid::kernel::activity::CommImplPtr comm =
@@ -389,9 +389,9 @@ void SIMIX_comm_finish(smx_activity_t synchro)
 
     /* Check out for errors */
 
-    if (not simcall->issuer->host_->is_on()) {
+    if (not simcall->issuer->get_host()->is_on()) {
       simcall->issuer->context_->iwannadie = true;
-      simcall->issuer->exception =
+      simcall->issuer->exception_ =
           std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
     } else {
       switch (comm->state_) {
@@ -402,12 +402,12 @@ void SIMIX_comm_finish(smx_activity_t synchro)
           break;
 
         case SIMIX_SRC_TIMEOUT:
-          simcall->issuer->exception = std::make_exception_ptr(
+          simcall->issuer->exception_ = std::make_exception_ptr(
               simgrid::TimeoutError(XBT_THROW_POINT, "Communication timeouted because of the sender"));
           break;
 
         case SIMIX_DST_TIMEOUT:
-          simcall->issuer->exception = std::make_exception_ptr(
+          simcall->issuer->exception_ = std::make_exception_ptr(
               simgrid::TimeoutError(XBT_THROW_POINT, "Communication timeouted because of the receiver"));
           break;
 
@@ -415,7 +415,7 @@ void SIMIX_comm_finish(smx_activity_t synchro)
           if (simcall->issuer == comm->src_actor_)
             simcall->issuer->context_->iwannadie = true;
           else
-            simcall->issuer->exception =
+            simcall->issuer->exception_ =
                 std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
           break;
 
@@ -423,16 +423,16 @@ void SIMIX_comm_finish(smx_activity_t synchro)
           if (simcall->issuer == comm->dst_actor_)
             simcall->issuer->context_->iwannadie = true;
           else
-            simcall->issuer->exception =
+            simcall->issuer->exception_ =
                 std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
           break;
 
         case SIMIX_LINK_FAILURE:
           XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) "
                     "detached:%d",
-                    synchro.get(), comm->src_actor_ ? comm->src_actor_->host_->get_cname() : nullptr,
-                    comm->dst_actor_ ? comm->dst_actor_->host_->get_cname() : nullptr, simcall->issuer->get_cname(),
-                    simcall->issuer, comm->detached);
+                    synchro.get(), comm->src_actor_ ? comm->src_actor_->get_host()->get_cname() : nullptr,
+                    comm->dst_actor_ ? comm->dst_actor_->get_host()->get_cname() : nullptr,
+                    simcall->issuer->get_cname(), simcall->issuer, comm->detached);
           if (comm->src_actor_ == simcall->issuer) {
             XBT_DEBUG("I'm source");
           } else if (comm->dst_actor_ == simcall->issuer) {
@@ -446,9 +446,11 @@ void SIMIX_comm_finish(smx_activity_t synchro)
 
         case SIMIX_CANCELED:
           if (simcall->issuer == comm->dst_actor_)
-            SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Communication canceled by the sender");
+            simcall->issuer->exception_ = std::make_exception_ptr(
+                simgrid::CancelException(XBT_THROW_POINT, "Communication canceled by the sender"));
           else
-            SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Communication canceled by the receiver");
+            simcall->issuer->exception_ = std::make_exception_ptr(
+                simgrid::CancelException(XBT_THROW_POINT, "Communication canceled by the receiver"));
           break;
 
         default:
@@ -457,7 +459,7 @@ void SIMIX_comm_finish(smx_activity_t synchro)
     }
 
     /* if there is an exception during a waitany or a testany, indicate the position of the failed communication */
-    if (simcall->issuer->exception &&
+    if (simcall->issuer->exception_ &&
         (simcall->call == SIMCALL_COMM_WAITANY || simcall->call == SIMCALL_COMM_TESTANY)) {
       // First retrieve the rank of our failing synchro
       int rank = -1;
@@ -476,20 +478,16 @@ void SIMIX_comm_finish(smx_activity_t synchro)
 
       // In order to modify the exception we have to rethrow it:
       try {
-        std::rethrow_exception(simcall->issuer->exception);
+        std::rethrow_exception(simcall->issuer->exception_);
       } catch (simgrid::TimeoutError& e) {
         e.value                    = rank;
-        simcall->issuer->exception = std::make_exception_ptr(e);
+        simcall->issuer->exception_ = std::make_exception_ptr(e);
       } catch (simgrid::NetworkFailureException& e) {
         e.value                    = rank;
-        simcall->issuer->exception = std::make_exception_ptr(e);
-      } catch (xbt_ex& e) {
-        if (e.category == cancel_error) {
-          e.value                    = rank;
-          simcall->issuer->exception = std::make_exception_ptr(e);
-        } else {
-          xbt_die("Unexpected xbt_ex(%s). Please enhance this code", xbt_ex_catname(e.category));
-        }
+        simcall->issuer->exception_ = std::make_exception_ptr(e);
+      } catch (simgrid::CancelException& e) {
+        e.value                    = rank;
+        simcall->issuer->exception_ = std::make_exception_ptr(e);
       }
     }
 
@@ -509,7 +507,7 @@ void SIMIX_comm_finish(smx_activity_t synchro)
       }
     }
 
-    if (simcall->issuer->host_->is_on())
+    if (simcall->issuer->get_host()->is_on())
       SIMIX_simcall_answer(simcall);
     else
       simcall->issuer->context_->iwannadie = true;