Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make ActorImpl::userdata private.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 25 Apr 2018 20:02:12 +0000 (22:02 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 25 Apr 2018 21:03:51 +0000 (23:03 +0200)
src/msg/msg_process.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_process.cpp

index ce9f382..fd37ef4 100644 (file)
@@ -35,7 +35,7 @@ void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_actor)
     msg_actor = (simgrid::msg::ActorExt*)SIMIX_process_self_get_data();
     SIMIX_process_self_set_data(nullptr);
   } else {
     msg_actor = (simgrid::msg::ActorExt*)SIMIX_process_self_get_data();
     SIMIX_process_self_set_data(nullptr);
   } else {
-    msg_actor = (simgrid::msg::ActorExt*)smx_actor->userdata;
+    msg_actor = (simgrid::msg::ActorExt*)smx_actor->getUserData();
     simcall_process_set_data(smx_actor, nullptr);
   }
 
     simcall_process_set_data(smx_actor, nullptr);
   }
 
@@ -212,7 +212,7 @@ void* MSG_process_get_data(msg_process_t process)
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
   /* get from SIMIX the MSG process data, and then the user data */
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
   /* get from SIMIX the MSG process data, and then the user data */
-  simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->get_impl()->userdata;
+  simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->get_impl()->getUserData();
   if (msgExt)
     return msgExt->data;
   else
   if (msgExt)
     return msgExt->data;
   else
@@ -228,7 +228,7 @@ msg_error_t MSG_process_set_data(msg_process_t process, void *data)
 {
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
 {
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
-  static_cast<simgrid::msg::ActorExt*>(process->get_impl()->userdata)->data = data;
+  static_cast<simgrid::msg::ActorExt*>(process->get_impl()->getUserData())->data = data;
 
   return MSG_OK;
 }
 
   return MSG_OK;
 }
index c6fa17a..a858523 100644 (file)
@@ -255,7 +255,7 @@ void create_maestro(std::function<void()> code)
   maestro           = new simgrid::kernel::actor::ActorImpl();
   maestro->pid = simix_process_maxpid++;
   maestro->name = "";
   maestro           = new simgrid::kernel::actor::ActorImpl();
   maestro->pid = simix_process_maxpid++;
   maestro->name = "";
-  maestro->userdata = nullptr;
+  maestro->setUserData(nullptr);
 
   if (not code) {
     maestro->context = SIMIX_context_new(std::function<void()>(), nullptr, maestro);
 
   if (not code) {
     maestro->context = SIMIX_context_new(std::function<void()>(), nullptr, maestro);
@@ -306,7 +306,7 @@ smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, v
   process->pid            = simix_process_maxpid++;
   process->name           = simgrid::xbt::string(name);
   process->host           = host;
   process->pid            = simix_process_maxpid++;
   process->name           = simgrid::xbt::string(name);
   process->host           = host;
-  process->userdata       = data;
+  process->setUserData(data);
   process->simcall.issuer = process;
 
   if (parent_process != nullptr) {
   process->simcall.issuer = process;
 
   if (parent_process != nullptr) {
@@ -366,7 +366,7 @@ smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostn
   process->pid = simix_process_maxpid++;
   process->name = std::string(name);
   process->host = host;
   process->pid = simix_process_maxpid++;
   process->name = std::string(name);
   process->host = host;
-  process->userdata       = data;
+  process->setUserData(data);
   process->simcall.issuer = process;
 
   if (parent_process != nullptr) {
   process->simcall.issuer = process;
 
   if (parent_process != nullptr) {
@@ -716,7 +716,7 @@ void SIMIX_process_yield(smx_actor_t self)
     SIMIX_process_on_exit_runall(self);
     /* Add the process to the list of process to restart, only if the host is down */
     if (self->auto_restart && self->host->isOff()) {
     SIMIX_process_on_exit_runall(self);
     /* Add the process to the list of process to restart, only if the host is down */
     if (self->auto_restart && self->host->isOff()) {
-      SIMIX_host_add_auto_restart_process(self->host, self->get_cname(), self->code, self->userdata,
+      SIMIX_host_add_auto_restart_process(self->host, self->get_cname(), self->code, self->getUserData(),
                                           SIMIX_timer_get_date(self->kill_timer), self->getProperties(),
                                           self->auto_restart);
     }
                                           SIMIX_timer_get_date(self->kill_timer), self->getProperties(),
                                           self->auto_restart);
     }
index 16dca7c..15bfeb0 100644 (file)
@@ -71,14 +71,14 @@ public:
   smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */
   std::list<smx_activity_t> comms;          /* the current non-blocking communication synchros */
   s_smx_simcall simcall;
   smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */
   std::list<smx_activity_t> comms;          /* the current non-blocking communication synchros */
   s_smx_simcall simcall;
-  void* userdata = nullptr;                      /* kept for compatibility, it should be replaced with moddata */
   std::vector<s_smx_process_exit_fun_t> on_exit; /* list of functions executed when the process dies */
 
   std::function<void()> code;
   smx_timer_t kill_timer = nullptr;
 
   std::vector<s_smx_process_exit_fun_t> on_exit; /* list of functions executed when the process dies */
 
   std::function<void()> code;
   smx_timer_t kill_timer = nullptr;
 
-  /* Refcounting */
 private:
 private:
+  void* userdata = nullptr; /* kept for compatibility, it should be replaced with moddata */
+  /* Refcounting */
   std::atomic_int_fast32_t refcount_{0};
 
 public:
   std::atomic_int_fast32_t refcount_{0};
 
 public:
index 6596885..c88ffb2 100644 (file)
@@ -87,7 +87,7 @@ simgrid::smpi::Process* smpi_process()
   ActorPtr me = Actor::self();
   if (me == nullptr) // This happens sometimes (eg, when linking against NS3 because it pulls openMPI...)
     return nullptr;
   ActorPtr me = Actor::self();
   if (me == nullptr) // This happens sometimes (eg, when linking against NS3 because it pulls openMPI...)
     return nullptr;
-  simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->get_impl()->userdata);
+  simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->get_impl()->getUserData());
   return static_cast<simgrid::smpi::Process*>(msgExt->data);
 }
 
   return static_cast<simgrid::smpi::Process*>(msgExt->data);
 }
 
index 72a8888..48459a9 100644 (file)
@@ -66,7 +66,7 @@ void Process::set_data(int* argc, char*** argv)
     finalization_barrier_ = barrier;
 
   process_                                                                  = simgrid::s4u::Actor::self();
     finalization_barrier_ = barrier;
 
   process_                                                                  = simgrid::s4u::Actor::self();
-  static_cast<simgrid::msg::ActorExt*>(process_->get_impl()->userdata)->data = this;
+  static_cast<simgrid::msg::ActorExt*>(process_->get_impl()->getUserData())->data = this;
 
   if (*argc > 3) {
     memmove(&(*argv)[0], &(*argv)[2], sizeof(char*) * (*argc - 2));
 
   if (*argc > 3) {
     memmove(&(*argv)[0], &(*argv)[2], sizeof(char*) * (*argc - 2));