X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0e51c90b78469c7c2067935ef62bf9474d09891d..f232c72280368ced3f5706dde1014d969dac3649:/include/simgrid/s4u/actor.hpp?ds=sidebyside diff --git a/include/simgrid/s4u/actor.hpp b/include/simgrid/s4u/actor.hpp index a58eb6ccd3..b671425915 100644 --- a/include/simgrid/s4u/actor.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -29,7 +29,7 @@ namespace s4u { * #include "s4u/actor.hpp" * * class Worker { - * int operator()() { + * void operator()() { * printf("Hello s4u"); * return 0; * } @@ -42,12 +42,12 @@ namespace s4u { XBT_PUBLIC_CLASS Actor { Actor(smx_process_t smx_proc); public: - Actor(const char* name, s4u::Host *host, double killTime, std::function code); - Actor(const char* name, s4u::Host *host, std::function code) + Actor(const char* name, s4u::Host *host, double killTime, std::function code); + Actor(const char* name, s4u::Host *host, std::function code) : Actor(name, host, -1, std::move(code)) {}; template Actor(const char* name, s4u::Host *host, C code) - : Actor(name, host, -1, std::function(std::move(code))) {} + : Actor(name, host, -1, std::function(std::move(code))) {} ~Actor(); /** Retrieves the actor that have the given PID (or NULL if not existing) */ @@ -79,30 +79,34 @@ public: /** Ask kindly to all actors to die. Only the issuer will survive. */ static void killAll(); +protected: + smx_process_t getInferior() {return pimpl_;} +private: + smx_process_t pimpl_ = nullptr; +}; + +namespace this_actor { + // Static methods working on the current actor: /** Block the actor sleeping for that amount of seconds (may throws hostFailure) */ - static void sleep(double duration); + void sleep(double duration); /** Block the actor, computing the given amount of flops */ - static e_smx_state_t execute(double flop); + e_smx_state_t execute(double flop); /** Block the actor until it gets a message from the given mailbox. * * See \ref Comm for the full communication API (including non blocking communications). */ - static void *recv(Mailbox &chan); + void *recv(Mailbox &chan); /** Block the actor until it delivers a message of the given simulated size to the given mailbox * * See \ref Comm for the full communication API (including non blocking communications). */ - static void send(Mailbox &chan, void*payload, size_t simulatedSize); + void send(Mailbox &chan, void*payload, size_t simulatedSize); -protected: - smx_process_t getInferior() {return pimpl_;} -private: - smx_process_t pimpl_ = nullptr; }; }} // namespace simgrid::s4u