Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce number of direct accesses to simix_global.
[simgrid.git] / src / s4u / s4u_Actor.cpp
index 5ec4612..80cd55a 100644 (file)
@@ -13,7 +13,6 @@
 #include "src/include/mc/mc.h"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/mc/mc_replay.hpp"
-#include "src/simix/smx_private.hpp"
 #include "src/surf/HostImpl.hpp"
 
 #include <algorithm>
@@ -43,6 +42,7 @@ Actor* Actor::self()
 
   return self_context->get_actor()->ciface();
 }
+
 ActorPtr Actor::init(const std::string& name, s4u::Host* host)
 {
   kernel::actor::ActorImpl* self = SIMIX_process_self();
@@ -218,10 +218,7 @@ double Actor::get_kill_time()
 void Actor::kill()
 {
   kernel::actor::ActorImpl* self = SIMIX_process_self();
-  kernel::actor::simcall([this, self] {
-    xbt_assert(pimpl_ != simix_global->maestro_process, "Killing maestro is a rather bad idea");
-    self->kill(pimpl_);
-  });
+  kernel::actor::simcall([this, self] { self->kill(pimpl_); });
 }
 
 // ***** Static functions *****
@@ -277,8 +274,7 @@ namespace this_actor {
  */
 bool is_maestro()
 {
-  kernel::actor::ActorImpl* self = SIMIX_process_self();
-  return self == nullptr || self == simix_global->maestro_process;
+  return SIMIX_is_maestro();
 }
 
 void sleep_for(double duration)
@@ -440,6 +436,19 @@ void migrate(Host* new_host)
 
 /* **************************** Public C interface *************************** */
 
+sg_actor_t sg_actor_init(const char* name, sg_host_t host)
+{
+  return simgrid::s4u::Actor::init(name, host).get();
+}
+
+void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv)
+{
+  simgrid::simix::ActorCode function;
+  if (code)
+    function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
+  actor->start(std::move(function));
+}
+
 /** @ingroup m_actor_management
  * @brief Returns the process ID of @a actor.
  *
@@ -516,7 +525,7 @@ xbt_dict_t sg_actor_get_properties(sg_actor_t actor)
   if (props == nullptr)
     return nullptr;
   for (auto const& kv : *props) {
-    xbt_dict_set(as_dict, kv.first.c_str(), xbt_strdup(kv.second.c_str()), nullptr);
+    xbt_dict_set(as_dict, kv.first.c_str(), xbt_strdup(kv.second.c_str()));
   }
   return as_dict;
 }