Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Deprecate a SIMIX function that was badly named anyway
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 20 Dec 2020 00:14:29 +0000 (01:14 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 20 Dec 2020 00:14:29 +0000 (01:14 +0100)
include/simgrid/simix.h
src/kernel/actor/ActorImpl.cpp
src/kernel/actor/ActorImpl.hpp
src/mc/mc_record.cpp
src/s4u/s4u_Actor.cpp

index 3c618e8..76d3573 100644 (file)
@@ -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();
index 050908b..f669bcd 100644 (file)
@@ -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,
index e32d7c7..dbac89e 100644 (file)
@@ -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);
index 2edd855..e266adf 100644 (file)
@@ -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:
index 1fd96f9..3827d4a 100644 (file)
@@ -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