Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[s4u] add kill actor with its PID
authoradfaure <adrien.faure2@gmail.com>
Mon, 6 Jun 2016 12:55:35 +0000 (14:55 +0200)
committeradfaure <adrien.faure2@gmail.com>
Mon, 6 Jun 2016 12:55:35 +0000 (14:55 +0200)
include/simgrid/s4u/actor.hpp
src/s4u/s4u_actor.cpp

index fd818b7..3e2ce5b 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef SIMGRID_S4U_ACTOR_HPP
 #define SIMGRID_S4U_ACTOR_HPP
 
+#include <stdexcept>
 #include <xbt/base.h>
 #include <simgrid/simix.h>
 #include <simgrid/s4u/forward.hpp>
@@ -74,6 +75,8 @@ public:
    */
   void kill();
 
+  static void kill(int PID);
+  
   // Static methods on all actors:
 
   /** Ask kindly to all actors to die. Only the issuer will survive. */
index a220c8c..6c2f29c 100644 (file)
@@ -53,6 +53,17 @@ double s4u::Actor::getKillTime() {
   return simcall_process_get_kill_time(pimpl_);
 }
 
+void s4u::Actor::kill(int PID) {
+  msg_process_t process = SIMIX_process_from_PID(PID);
+  if(process != NULL) {
+    simcall_process_kill(process);
+  } else {
+    std::ostringstream oss;
+    oss << "kill: ("<< PID <<") - No such process" << std::endl;
+    throw std::runtime_error(oss.str());
+  }
+}
+
 void s4u::Actor::kill() {
   simcall_process_kill(pimpl_);
 }