From 5ecdb12a2a573df415d8677c2455e1662e276f90 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 25 Apr 2018 22:02:12 +0200 Subject: [PATCH] Make ActorImpl::userdata private. --- src/msg/msg_process.cpp | 6 +++--- src/simix/ActorImpl.cpp | 8 ++++---- src/simix/ActorImpl.hpp | 4 ++-- src/smpi/internals/smpi_global.cpp | 2 +- src/smpi/internals/smpi_process.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index ce9f382795..fd37ef49ed 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -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*)smx_actor->userdata; + msg_actor = (simgrid::msg::ActorExt*)smx_actor->getUserData(); 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 */ - 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 @@ -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!"); - static_cast(process->get_impl()->userdata)->data = data; + static_cast(process->get_impl()->getUserData())->data = data; return MSG_OK; } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index c6fa17a68b..a8585230b6 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -255,7 +255,7 @@ void create_maestro(std::function code) 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(), nullptr, maestro); @@ -306,7 +306,7 @@ smx_actor_t SIMIX_process_create(const char* name, std::function code, v 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) { @@ -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->userdata = data; + process->setUserData(data); 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_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); } diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index 16dca7c427..15bfeb04cb 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -71,14 +71,14 @@ public: smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */ std::list 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 on_exit; /* list of functions executed when the process dies */ std::function code; smx_timer_t kill_timer = nullptr; - /* Refcounting */ private: + void* userdata = nullptr; /* kept for compatibility, it should be replaced with moddata */ + /* Refcounting */ std::atomic_int_fast32_t refcount_{0}; public: diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 65968853df..c88ffb2751 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -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; - simgrid::msg::ActorExt* msgExt = static_cast(me->get_impl()->userdata); + simgrid::msg::ActorExt* msgExt = static_cast(me->get_impl()->getUserData()); return static_cast(msgExt->data); } diff --git a/src/smpi/internals/smpi_process.cpp b/src/smpi/internals/smpi_process.cpp index 72a888834c..48459a994f 100644 --- a/src/smpi/internals/smpi_process.cpp +++ b/src/smpi/internals/smpi_process.cpp @@ -66,7 +66,7 @@ void Process::set_data(int* argc, char*** argv) finalization_barrier_ = barrier; process_ = simgrid::s4u::Actor::self(); - static_cast(process_->get_impl()->userdata)->data = this; + static_cast(process_->get_impl()->getUserData())->data = this; if (*argc > 3) { memmove(&(*argv)[0], &(*argv)[2], sizeof(char*) * (*argc - 2)); -- 2.20.1