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();
{
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()
{
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,
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);
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:
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