]> AND Public Git Repository - simgrid.git/blobdiff - src/kernel/activity/ExecImpl.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill commented code.
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
index fdaf2dcc046bd2b239f76cec84c1d31f4b539446..789082c1e31d872ef70b35fb8a8ce0a8b5f7536e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -25,14 +25,13 @@ ExecImpl::ExecImpl()
   actor::ActorImpl* self = actor::ActorImpl::self();
   if (self) {
     set_actor(self);
-    self->activities_.emplace_back(this);
+    self->activities_.insert(this);
   }
 }
 
 ExecImpl& ExecImpl::set_host(s4u::Host* host)
 {
-  clear_hosts();
-  add_host(host);
+  ActivityImpl::set_hosts({host});
   return *this;
 }
 
@@ -146,21 +145,18 @@ ExecImpl& ExecImpl::update_sharing_penalty(double sharing_penalty)
 void ExecImpl::post()
 {
   xbt_assert(surf_action_ != nullptr);
-  auto hosts=get_hosts();
-  if (std::any_of(hosts.begin(), hosts.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
+  if (auto const& hosts = get_hosts();
+      std::any_of(hosts.begin(), hosts.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
     /* If one of the hosts running the synchro failed, notice it. This way, the asking
      * process can be killed if it runs on that host itself */
     set_state(State::FAILED);
   } else if (surf_action_->get_state() == resource::Action::State::FAILED) {
     /* If all the hosts are running the synchro didn't fail, then the synchro was canceled */
     set_state(State::CANCELED);
-  } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED) {
-    if (surf_action_->get_remains() > 0.0) {
-      surf_action_->set_state(resource::Action::State::FAILED);
-      set_state(State::TIMEOUT);
-    } else {
-      set_state(State::DONE);
-    }
+  } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED &&
+             surf_action_->get_remains() > 0.0) {
+    surf_action_->set_state(resource::Action::State::FAILED);
+    set_state(State::TIMEOUT);
   } else {
     set_state(State::DONE);
   }
@@ -168,7 +164,7 @@ void ExecImpl::post()
   clean_action();
   timeout_detector_.reset();
   if (get_actor() != nullptr) {
-    get_actor()->activities_.remove(this);
+    get_actor()->activities_.erase(this);
   }
   if (get_state() != State::FAILED && cb_id_ >= 0)
     s4u::Host::on_state_change.disconnect(cb_id_);