From: Gabriel Corona Date: Tue, 21 Jun 2016 15:03:02 +0000 (+0200) Subject: [s4u] Actor::forPid() X-Git-Tag: v3_14~896 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4fd0a2b6cf055692f936e29294496d14a6091ff1 [s4u] Actor::forPid() --- diff --git a/include/simgrid/s4u/actor.hpp b/include/simgrid/s4u/actor.hpp index e983372ffd..7f8016f4fc 100644 --- a/include/simgrid/s4u/actor.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -231,6 +231,7 @@ public: void kill(); static void kill(int pid); + static Actor forPid(int pid); /** * Wait for the actor to finish. @@ -242,6 +243,8 @@ public: /** Ask kindly to all actors to die. Only the issuer will survive. */ static void killAll(); + bool valid() const { return pimpl_ != nullptr; } + private: smx_process_t pimpl_ = nullptr; }; diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index d5d5e9963d..5cec45afd9 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -68,6 +68,13 @@ void s4u::Actor::kill() { simcall_process_kill(pimpl_); } +simgrid::s4u::Actor s4u::Actor::forPid(int pid) +{ + // Should we throw if we did not find it? + smx_process_t process = SIMIX_process_from_PID(pid); + return simgrid::s4u::Actor(process); +} + // static stuff: void s4u::Actor::killAll() {