X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3ad51daf5c4c7d42a0e55e00498b0c9de202b9e4..0a95c78251f3ecbf1dfcb3ebe7904e44acf1beef:/include/simgrid/s4u/Actor.hpp diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 1eb18d1ffc..56567c440f 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -18,6 +18,7 @@ #include +#include #include #include #include @@ -131,9 +132,12 @@ namespace s4u { */ /** @brief Simulation Agent */ -XBT_PUBLIC_CLASS Actor { +XBT_PUBLIC_CLASS Actor : public simgrid::xbt::Extendable +{ + friend Mailbox; friend simgrid::simix::ActorImpl; + friend simgrid::kernel::activity::MailboxImpl; simix::ActorImpl* pimpl_ = nullptr; /** Wrap a (possibly non-copyable) single-use task into a `std::function` */ @@ -176,12 +180,7 @@ public: * * If the actor is restarted, the actor has a fresh copy of the function. */ - static ActorPtr createActor(const char* name, s4u::Host *host, double killTime, std::function code); - - static ActorPtr createActor(const char* name, s4u::Host *host, std::function code) - { - return createActor(name, host, -1.0, std::move(code)); - } + static ActorPtr createActor(const char* name, s4u::Host* host, std::function code); /** Create an actor using code * @@ -201,50 +200,43 @@ public: // Create actor from function name: - static ActorPtr createActor(const char* name, s4u::Host *host, double killTime, - const char* function, std::vector args); - - static ActorPtr createActor(const char* name, s4u::Host *host, const char* function, - std::vector args) - { - return createActor(name, host, -1.0, function, std::move(args)); - } + static ActorPtr createActor(const char* name, s4u::Host* host, const char* function, std::vector args); // ***** Methods ***** - /** Retrieves the actor that have the given PID (or NULL if not existing) */ - //static Actor *byPid(int pid); not implemented - /** Retrieves the name of that actor */ - simgrid::xbt::string getName(); + simgrid::xbt::string name(); /** Retrieves the host on which that actor is running */ - s4u::Host *getHost(); + s4u::Host* host(); /** Retrieves the PID of that actor */ - int getPid(); + int pid(); /** Retrieves the PPID of that actor */ - int getPpid(); + int ppid(); /** If set to true, the actor will automatically restart when its host reboots */ void setAutoRestart(bool autorestart); /** Sets the time at which that actor should be killed */ void setKillTime(double time); /** Retrieves the time at which that actor will be killed (or -1 if not set) */ - double getKillTime(); + double killTime(); /** Ask the actor to die. * * It will only notice your request when doing a simcall next time (a communication or similar). * SimGrid sometimes have issues when you kill actors that are currently communicating and such. - * We are working on it to fix the issues. + * Still. Please report any bug that you may encounter with a minimal working example. */ void kill(); static void kill(int pid); - static ActorPtr forPid(int pid); - - /** - * Wait for the actor to finish. - */ + + /** Retrieves the actor that have the given PID (or nullptr if not existing) */ + static ActorPtr byPid(int pid); + + /** @brief Wait for the actor to finish. + * + * This blocks the calling actor until the actor on which we call join() is terminated + */ void join(); // Static methods on all actors: @@ -254,7 +246,7 @@ public: protected: /** Returns the internal implementation of this actor */ - smx_actor_t getImpl(); + simix::ActorImpl* getImpl(); }; /** @ingroup s4u_api @@ -298,17 +290,12 @@ namespace this_actor { * See \ref Comm for the full communication API (including non blocking communications). */ XBT_PUBLIC(void) send(MailboxPtr chan, void*payload, size_t simulatedSize); - - /** - * Return the PID of the current actor. - */ - XBT_PUBLIC(int) getPid(); - - /** - * Return the PPID of the current actor. - */ - int getPpid(); + /** @brief Return the PID of the current actor. */ + XBT_PUBLIC(int) pid(); + + /** @brief Return the PPID of the current actor. */ + int ppid(); }; /** @} */