Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
improve the s4u::Actor API (and mimick the one of rsg::Actor)
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Mar 2016 21:22:16 +0000 (22:22 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Mar 2016 21:22:16 +0000 (22:22 +0100)
include/simgrid/s4u/actor.hpp
src/s4u/s4u_actor.cpp

index 680bcd6..9860051 100644 (file)
@@ -49,7 +49,7 @@ public:
   virtual int main(int argc, char **argv);
 
   /** The Actor that is currently running */
-  static Actor *current();
+  static Actor &self();
   /** Retrieves the actor that have the given PID (or NULL if not existing) */
   //static Actor *byPid(int pid); not implemented
 
index 4e7594c..e1358a5 100644 (file)
@@ -44,13 +44,13 @@ int s4u::Actor::main(int argc, char **argv) {
   fprintf(stderr,"Error: You should override the method main(int, char**) in Actor class %s\n",getName());
   return 0;
 }
-s4u::Actor *s4u::Actor::current()
+s4u::Actor &s4u::Actor::self()
 {
   smx_process_t smx_proc = SIMIX_process_self();
   simgrid::s4u::Actor* res = (simgrid::s4u::Actor*) SIMIX_process_self_get_data();
   if (res == NULL) // The smx_process was not created by S4U (but by deployment?). Embed it in a S4U object
     res = new Actor(smx_proc);
-  return res;
+  return *res;
 }
 
 void s4u::Actor::setAutoRestart(bool autorestart) {