Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Misc. cosmetic changes.
[simgrid.git] / src / kernel / actor / ActorImpl.cpp
index d3b4ebf..801eb53 100644 (file)
@@ -3,23 +3,15 @@
 /* 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. */
 
-#include "simgrid/s4u/Actor.hpp"
-#include "mc/mc.h"
-#include "simgrid/Exception.hpp"
-#include "simgrid/s4u/Exec.hpp"
+#include <simgrid/Exception.hpp>
+#include <simgrid/s4u/Actor.hpp>
+#include <simgrid/s4u/Host.hpp>
+
 #include "src/kernel/EngineImpl.hpp"
-#include "src/kernel/activity/CommImpl.hpp"
-#include "src/kernel/activity/ExecImpl.hpp"
-#include "src/kernel/activity/IoImpl.hpp"
-#include "src/kernel/activity/SleepImpl.hpp"
-#include "src/kernel/activity/SynchroRaw.hpp"
-#include "src/mc/mc_replay.hpp"
-#include "src/mc/remote/AppSide.hpp"
 #if HAVE_SMPI
 #include "src/smpi/include/private.hpp"
 #endif
 #include "src/surf/HostImpl.hpp"
-#include "src/surf/cpu_interface.hpp"
 
 #include <boost/core/demangle.hpp>
 #include <typeinfo>
@@ -34,7 +26,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix, "Logging specific to SIMIX
  *
  * @return The SIMIX process
  */
-smx_actor_t SIMIX_process_self()
+smx_actor_t SIMIX_process_self() // XBT_ATTRIB_DEPRECATED_v333
 {
   return simgrid::kernel::actor::ActorImpl::self();
 }
@@ -73,7 +65,7 @@ ActorImpl::ActorImpl(xbt::string name, s4u::Host* host) : host_(host), name_(std
 
 ActorImpl::~ActorImpl()
 {
-  if (not EngineImpl::get_instance()->is_maestro(this))
+  if (EngineImpl::has_instance() && not EngineImpl::get_instance()->is_maestro(this))
     s4u::Actor::on_destruction(*get_ciface());
 }
 
@@ -234,7 +226,8 @@ void ActorImpl::exit()
 
 void ActorImpl::kill(ActorImpl* actor) const
 {
-  xbt_assert(not EngineImpl::get_instance()->is_maestro(actor), "Killing maestro is a rather bad idea");
+  auto* engine = EngineImpl::get_instance();
+  xbt_assert(not engine->is_maestro(actor), "Killing maestro is a rather bad idea");
   if (actor->finished_) {
     XBT_DEBUG("Ignoring request to kill actor %s@%s that is already dead", actor->get_cname(),
               actor->host_->get_cname());
@@ -249,7 +242,7 @@ void ActorImpl::kill(ActorImpl* actor) const
   if (actor == this) {
     XBT_DEBUG("Go on, this is a suicide,");
   } else
-    EngineImpl::get_instance()->add_actor_to_run_list(actor);
+    engine->add_actor_to_run_list(actor);
 }
 
 void ActorImpl::kill_all() const
@@ -518,16 +511,15 @@ void create_maestro(const std::function<void()>& code)
   }
 
   maestro->simcall_.issuer_ = maestro;
-  EngineImpl::get_instance()->set_maestro(maestro);
+  engine->set_maestro(maestro);
 }
 
 } // namespace actor
 } // namespace kernel
 } // namespace simgrid
 
-/* needs to be public and without simcall because it is called
-   by exceptions and logging events */
-const char* SIMIX_process_self_get_name()
+/* needs to be public and without simcall because it is called by exceptions and logging events */
+const char* SIMIX_process_self_get_name() // XBT_ATTRIB_DEPRECATED_v333
 {
   return SIMIX_is_maestro() ? "maestro" : simgrid::kernel::actor::ActorImpl::self()->get_cname();
 }
@@ -537,3 +529,9 @@ smx_actor_t SIMIX_process_from_PID(aid_t pid) // XBT_ATTRIB_DEPRECATD_v331
 {
   return simgrid::kernel::actor::ActorImpl::by_pid(pid);
 }
+
+int SIMIX_is_maestro()
+{
+  const auto* self = simgrid::kernel::actor::ActorImpl::self();
+  return self == nullptr || simgrid::kernel::EngineImpl::get_instance()->is_maestro(self);
+}