Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce number of direct accesses to simix_global.
[simgrid.git] / src / kernel / actor / ActorImpl.cpp
index afb141f..5f5bb59 100644 (file)
@@ -98,7 +98,7 @@ ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* h
     actor->set_properties(*properties);
 
   /* Add the process to it's host process list */
     actor->set_properties(*properties);
 
   /* Add the process to it's host process list */
-  host->pimpl_->actor_list_.push_back(*actor);
+  host->pimpl_->add_actor(actor);
 
   /* Now insert it in the global process list and in the process to run list */
   simix_global->process_list[actor->get_pid()] = actor;
 
   /* Now insert it in the global process list and in the process to run list */
   simix_global->process_list[actor->get_pid()] = actor;
@@ -172,7 +172,7 @@ void ActorImpl::cleanup()
 
   simix_global->process_list.erase(pid_);
   if (host_ && host_actor_list_hook.is_linked())
 
   simix_global->process_list.erase(pid_);
   if (host_ && host_actor_list_hook.is_linked())
-    simgrid::xbt::intrusive_erase(host_->pimpl_->actor_list_, *this);
+    host_->pimpl_->remove_actor(this);
   if (not smx_destroy_list_hook.is_linked()) {
 #if SIMGRID_HAVE_MC
     xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this);
   if (not smx_destroy_list_hook.is_linked()) {
 #if SIMGRID_HAVE_MC
     xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this);
@@ -222,6 +222,7 @@ void ActorImpl::exit()
 
 void ActorImpl::kill(ActorImpl* actor)
 {
 
 void ActorImpl::kill(ActorImpl* actor)
 {
+  xbt_assert(actor != simix_global->maestro_process, "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());
   if (actor->finished_) {
     XBT_DEBUG("Ignoring request to kill actor %s@%s that is already dead", actor->get_cname(),
               actor->host_->get_cname());
@@ -443,9 +444,9 @@ void ActorImpl::simcall_answer()
 
 void ActorImpl::set_host(s4u::Host* dest)
 {
 
 void ActorImpl::set_host(s4u::Host* dest)
 {
-  xbt::intrusive_erase(host_->pimpl_->actor_list_, *this);
+  host_->pimpl_->remove_actor(this);
   host_ = dest;
   host_ = dest;
-  dest->pimpl_->actor_list_.push_back(*this);
+  dest->pimpl_->add_actor(this);
 }
 
 ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host)
 }
 
 ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host)
@@ -477,7 +478,7 @@ ActorImpl* ActorImpl::start(const simix::ActorCode& code)
   XBT_DEBUG("Start context '%s'", get_cname());
 
   /* Add the actor to its host's actor list */
   XBT_DEBUG("Start context '%s'", get_cname());
 
   /* Add the actor to its host's actor list */
-  host_->pimpl_->actor_list_.push_back(*this);
+  host_->pimpl_->add_actor(this);
   simix_global->process_list[pid_] = this;
 
   /* Now insert it in the global actor list and in the actor to run list */
   simix_global->process_list[pid_] = this;
 
   /* Now insert it in the global actor list and in the actor to run list */
@@ -553,12 +554,7 @@ void SIMIX_process_self_set_data(void* data)
    by exceptions and logging events */
 const char* SIMIX_process_self_get_name()
 {
    by exceptions and logging events */
 const char* SIMIX_process_self_get_name()
 {
-
-  smx_actor_t process = SIMIX_process_self();
-  if (process == nullptr || process == simix_global->maestro_process)
-    return "maestro";
-
-  return process->get_cname();
+  return SIMIX_is_maestro() ? "maestro" : SIMIX_process_self()->get_cname();
 }
 
 /**
 }
 
 /**