From: Martin Quinson Date: Sun, 20 Dec 2020 00:14:29 +0000 (+0100) Subject: Deprecate a SIMIX function that was badly named anyway X-Git-Tag: v3.27~584 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9635773a7faace54a277b9c75b8f44fe1df0b36f Deprecate a SIMIX function that was badly named anyway --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 3c618e8017..76d35736d3 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -23,7 +23,8 @@ extern unsigned smx_context_guard_size; SG_BEGIN_DECL -XBT_PUBLIC smx_actor_t SIMIX_process_from_PID(aid_t PID); +XBT_ATTRIB_DEPRECATED_v331("Please use sg_actor_by_PID instead.") XBT_PUBLIC smx_actor_t + SIMIX_process_from_PID(aid_t PID); /* parallelism */ XBT_PUBLIC int SIMIX_context_is_parallel(); diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 050908b2b8..f669bcd3e4 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -44,6 +44,18 @@ unsigned long get_maxpid() { return maxpid; } +ActorImpl* ActorImpl::by_PID(aid_t PID) +{ + auto item = simix_global->process_list.find(PID); + if (item != simix_global->process_list.end()) + return item->second; + + // Search the trash + for (auto& a : simix_global->actors_to_destroy) + if (a.get_pid() == PID) + return &a; + return nullptr; // Not found, even in the trash +} ActorImpl* ActorImpl::self() { @@ -562,25 +574,10 @@ const char* SIMIX_process_self_get_name() return SIMIX_is_maestro() ? "maestro" : simgrid::kernel::actor::ActorImpl::self()->get_cname(); } -/** - * @brief Calling this function makes the process to yield. - * - * Only the current process can call this function, giving back the control to maestro. - * - * @param self the current process - */ - /** @brief Returns the process from PID. */ smx_actor_t SIMIX_process_from_PID(aid_t PID) { - auto item = simix_global->process_list.find(PID); - if (item == simix_global->process_list.end()) { - for (auto& a : simix_global->actors_to_destroy) - if (a.get_pid() == PID) - return &a; - return nullptr; // Not found, even in the trash - } - return item->second; + return simgrid::kernel::actor::ActorImpl::by_PID(PID); } void SIMIX_process_on_exit(smx_actor_t actor, diff --git a/src/kernel/actor/ActorImpl.hpp b/src/kernel/actor/ActorImpl.hpp index e32d7c766b..dbac89e60b 100644 --- a/src/kernel/actor/ActorImpl.hpp +++ b/src/kernel/actor/ActorImpl.hpp @@ -35,6 +35,9 @@ public: ActorImpl& operator=(const ActorImpl&) = delete; ~ActorImpl(); + /** Retrieve the actor implementation from its PID (or nullptr if non-existent) */ + static ActorImpl* by_PID(aid_t PID); + static ActorImpl* self(); double get_kill_time() const; void set_kill_time(double kill_time); diff --git a/src/mc/mc_record.cpp b/src/mc/mc_record.cpp index 2edd855789..e266adf88c 100644 --- a/src/mc/mc_record.cpp +++ b/src/mc/mc_record.cpp @@ -31,13 +31,13 @@ void replay(RecordTrace const& trace) XBT_DEBUG("Executing %i$%i", transition.pid_, transition.argument_); // Choose a request: - smx_actor_t process = SIMIX_process_from_PID(transition.pid_); - if (not process) - xbt_die("Unexpected process (pid:%d).", transition.pid_); - const s_smx_simcall* simcall = &(process->simcall_); + kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(transition.pid_); + if (actor == nullptr) + xbt_die("Unexpected actor (id:%d).", transition.pid_); + const s_smx_simcall* simcall = &(actor->simcall_); if (simcall->call_ == simix::Simcall::NONE) xbt_die("No simcall for process %d.", transition.pid_); - if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process)) + if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(actor)) xbt_die("Unexpected simcall."); // Execute the request: diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 1fd96f9383..3827d4aa98 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -260,7 +260,7 @@ void Actor::kill() ActorPtr Actor::by_pid(aid_t pid) { - kernel::actor::ActorImpl* actor = SIMIX_process_from_PID(pid); + kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(pid); if (actor != nullptr) return actor->get_iface(); else