Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Action::finish() is never used without setState().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 29 Sep 2017 20:23:01 +0000 (22:23 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 29 Sep 2017 20:28:30 +0000 (22:28 +0200)
Add the new state as a parameter for finish().

src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp
src/surf/network_cm02.cpp
src/surf/network_constant.cpp
src/surf/network_ns3.cpp
src/surf/ptask_L07.cpp
src/surf/storage_n11.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp

index e8282cb..7a6dc74 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -34,12 +34,11 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
                                       action->getLastUpdate(), now - action->getLastUpdate());
     }
 
-    action->finish();
+    action->finish(Action::State::done);
     XBT_CDEBUG(surf_kernel, "Action %p finished", action);
 
     /* set the remains to 0 due to precision problems when updating the remaining amount */
     action->setRemains(0);
-    action->setState(Action::State::done);
   }
   if (TRACE_is_enabled()) {
     //defining the last timestamp that we can safely dump to trace file
@@ -84,8 +83,7 @@ void CpuModel::updateActionsStateFull(double now, double delta)
 
     if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
         ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
-      action->finish();
-      action->setState(Action::State::done);
+      action->finish(Action::State::done);
     }
   }
 }
index 5366483..454efa8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -380,10 +380,9 @@ void CpuTiModel::updateActionsState(double now, double /*delta*/)
   while ((xbt_heap_size(tiActionHeap_) > 0) && (xbt_heap_maxkey(tiActionHeap_) <= now)) {
     CpuTiAction *action = static_cast<CpuTiAction*>(xbt_heap_pop(tiActionHeap_));
     XBT_DEBUG("Action %p: finish", action);
-    action->finish();
+    action->finish(Action::State::done);
     /* set the remains to 0 due to precision problems when updating the remaining amount */
     action->setRemains(0);
-    action->setState(Action::State::done);
     /* update remaining amount of all actions */
     action->cpu_->updateRemainingAmount(surf_get_clock());
   }
index e0ae4e4..d3e8809 100644 (file)
@@ -204,8 +204,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
         // assume that flows that reached max_duration have remaining of 0
       XBT_DEBUG("Action %p finished", action);
       action->setRemains(0);
-      action->finish();
-      action->setState(Action::State::done);
+      action->finish(Action::State::done);
       action->heapRemove(actionHeap_);
     }
   }
@@ -259,8 +258,7 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta)
 
     if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
         ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
-      action->finish();
-      action->setState(Action::State::done);
+      action->finish(Action::State::done);
     }
   }
 }
@@ -492,8 +490,7 @@ void NetworkCm02Action::updateRemainingLazy(double now)
 
   if ((remains_ <= 0 && (lmm_get_variable_weight(getVariable()) > 0)) ||
       ((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
-    finish();
-    setState(Action::State::done);
+    finish(Action::State::done);
     heapRemove(getModel()->getActionHeap());
   }
 
index 35a66b6..dcbc87f 100644 (file)
@@ -68,8 +68,7 @@ void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
 
     if (((action->getRemainsNoUpdate() <= 0) ||
          ((action->getMaxDuration() != NO_MAX_DURATION) && (action->getMaxDuration() <= 0)))) {
-      action->finish();
-      action->setState(Action::State::done);
+      action->finish(Action::State::done);
     }
   }
 }
index fe0fdee..a9139b1 100644 (file)
@@ -237,8 +237,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
     if(sgFlow->finished_){
       xbt_dynar_push(socket_to_destroy,&ns3Socket);
       XBT_DEBUG("Destroy socket %p of action %p", ns3Socket, action);
-      action->finish();
-      action->setState(Action::State::done);
+      action->finish(Action::State::done);
     }
   }
 
index c1750d7..b3d5bea 100644 (file)
@@ -129,8 +129,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) {
 
     if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
         ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
-      action->finish();
-      action->setState(Action::State::done);
+      action->finish(Action::State::done);
     } else {
       /* Need to check that none of the model has failed */
       int i = 0;
@@ -140,8 +139,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) {
         void *constraint_id = lmm_constraint_id(cnst);
         if (static_cast<simgrid::surf::Resource*>(constraint_id)->isOff()) {
           XBT_DEBUG("Action (%p) Failed!!", action);
-          action->finish();
-          action->setState(Action::State::failed);
+          action->finish(Action::State::failed);
           break;
         }
         cnst = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
index a27852b..d8bfca3 100644 (file)
@@ -98,12 +98,10 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
 
     if (action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 &&
         action->storage_->usedSize_ == action->storage_->getSize()) {
-      action->finish();
-      action->setState(Action::State::failed);
+      action->finish(Action::State::failed);
     } else if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
                ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
-      action->finish();
-      action->setState(Action::State::done);
+      action->finish(Action::State::done);
     }
   }
 }
index a8a7239..b0007c1 100644 (file)
@@ -634,8 +634,10 @@ Action::~Action() {
   xbt_free(category_);
 }
 
-void Action::finish() {
+void Action::finish(Action::State state)
+{
   finishTime_ = surf_get_clock();
+  setState(state);
 }
 
 Action::State Action::getState()
@@ -880,8 +882,7 @@ void Action::updateRemainingLazy(double now)
     //FIXME: duplicated code
     if (((remains_ <= 0) && (lmm_get_variable_weight(getVariable()) > 0)) ||
         ((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
-      finish();
-      setState(Action::State::done);
+      finish(Action::State::done);
       heapRemove(getModel()->getActionHeap());
     }
   }
index 65eea27..0d3c6fd 100644 (file)
@@ -118,8 +118,12 @@ public:
   /** @brief Destructor */
   virtual ~Action();
 
-  /** @brief Mark that the action is now finished */
-  void finish();
+  /**
+   * @brief Mark that the action is now finished
+   *
+   * @param state the new [state](\ref simgrid::surf::Action::State) of the current Action
+   */
+  void finish(Action::State state);
 
   /** @brief Get the [state](\ref simgrid::surf::Action::State) of the current Action */
   Action::State getState(); /**< get the state*/