From: Martin Quinson Date: Thu, 10 Mar 2016 21:22:16 +0000 (+0100) Subject: improve the s4u::Actor API (and mimick the one of rsg::Actor) X-Git-Tag: v3_13~450^2~9 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/14f01dda6ef1164f5c13f19c8cd4d5440faa9c4a improve the s4u::Actor API (and mimick the one of rsg::Actor) --- diff --git a/include/simgrid/s4u/actor.hpp b/include/simgrid/s4u/actor.hpp index 680bcd6d7d..9860051f06 100644 --- a/include/simgrid/s4u/actor.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -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 diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 4e7594c4f8..e1358a58d6 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -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) {