Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please codacy: use long form of negation in C++
[simgrid.git] / src / kernel / activity / SynchroComm.cpp
index 4367536..1949b21 100644 (file)
@@ -11,9 +11,9 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_network);
 
-simgrid::kernel::activity::Comm::Comm(e_smx_comm_type_t _type) {
+simgrid::kernel::activity::Comm::Comm(e_smx_comm_type_t _type) : type(_type)
+{
   state = SIMIX_WAITING;
-  this->type = _type;
   src_data=nullptr;
   dst_data=nullptr;
 
@@ -35,8 +35,7 @@ simgrid::kernel::activity::Comm::~Comm()
   }
 
   if(mbox)
-    SIMIX_mbox_remove(mbox, this);
-
+    mbox->remove(this);
 }
 void simgrid::kernel::activity::Comm::suspend()
 {
@@ -60,12 +59,10 @@ void simgrid::kernel::activity::Comm::cancel()
   /* if the synchro is a waiting state means that it is still in a mbox */
   /* so remove from it and delete it */
   if (state == SIMIX_WAITING) {
-    SIMIX_mbox_remove(mbox, this);
+    mbox->remove(this);
     state = SIMIX_CANCELED;
-  }
-  else if (!MC_is_active() /* when running the MC there are no surf actions */
-           && !MC_record_replay_is_active()
-           && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
+  } else if (not MC_is_active() /* when running the MC there are no surf actions */
+             && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
 
     surf_comm->cancel();
   }
@@ -74,21 +71,11 @@ void simgrid::kernel::activity::Comm::cancel()
 /**  @brief get the amount remaining from the communication */
 double simgrid::kernel::activity::Comm::remains()
 {
-  switch (state) {
-
-  case SIMIX_RUNNING:
+  if (state == SIMIX_RUNNING)
     return surf_comm->getRemains();
-    break;
-
-  case SIMIX_WAITING:
-  case SIMIX_READY:
-    return 0; /*FIXME: check what should be returned */
-    break;
 
-  default:
-    return 0; /*FIXME: is this correct? */
-    break;
-  }
+  /* FIXME: check what should be returned in the other cases */
+  return 0;
 }
 
 /** @brief This is part of the cleanup process, probably an internal command */
@@ -133,6 +120,6 @@ void simgrid::kernel::activity::Comm::post()
   cleanupSurf();
 
   /* if there are simcalls associated with the synchro, then answer them */
-  if (!simcalls.empty())
+  if (not simcalls.empty())
     SIMIX_comm_finish(this);
 }