X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/755eca55d26d26cf6a09369dfffe9359c2b2f847..96b18f4b65694f66c8aea2d702b6f087fdcf9cb7:/include/simgrid/s4u/Actor.hpp diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 7f3f4a6267..fe29ab2d24 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -132,8 +132,8 @@ namespace s4u { /** @brief Simulation Agent (see \ref s4u_actor)*/ XBT_PUBLIC_CLASS Actor { friend Mailbox; - friend simgrid::simix::Process; - smx_process_t pimpl_ = nullptr; + friend simgrid::simix::ActorImpl; + smx_actor_t pimpl_ = nullptr; /** Wrap a (possibly non-copyable) single-use task into a `std::function` */ template @@ -147,7 +147,7 @@ XBT_PUBLIC_CLASS Actor { }; } - explicit Actor(smx_process_t pimpl) : pimpl_(pimpl) {} + explicit Actor(smx_actor_t pimpl) : pimpl_(pimpl) {} public: @@ -168,19 +168,18 @@ public: xbt_assert(actor != nullptr); SIMIX_process_unref(actor->pimpl_); } - using Ptr = boost::intrusive_ptr; // ***** Actor creation ***** /** Retrieve a reference to myself */ - static Ptr self(); + static ActorPtr self(); /** Create an actor using a function * * If the actor is restarted, the actor has a fresh copy of the function. */ - static Ptr createActor(const char* name, s4u::Host *host, double killTime, std::function code); + static ActorPtr createActor(const char* name, s4u::Host *host, double killTime, std::function code); - static Ptr createActor(const char* name, s4u::Host *host, std::function code) + static ActorPtr createActor(const char* name, s4u::Host *host, std::function code) { return createActor(name, host, -1.0, std::move(code)); } @@ -196,17 +195,17 @@ public: // This constructor is enabled only if the call code(args...) is valid: typename = typename std::result_of::type > - static Ptr createActor(const char* name, s4u::Host *host, F code, Args... args) + static ActorPtr createActor(const char* name, s4u::Host *host, F code, Args... args) { return createActor(name, host, wrap_task(std::move(code), std::move(args)...)); } // Create actor from function name: - static Ptr createActor(const char* name, s4u::Host *host, double killTime, + static ActorPtr createActor(const char* name, s4u::Host *host, double killTime, const char* function, std::vector args); - static Ptr createActor(const char* name, s4u::Host *host, const char* function, + 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)); @@ -223,6 +222,8 @@ public: s4u::Host *getHost(); /** Retrieves the PID of that actor */ int getPid(); + /** Retrieves the PPID of that actor */ + int getPpid(); /** If set to true, the actor will automatically restart when its host reboots */ void setAutoRestart(bool autorestart); @@ -240,7 +241,7 @@ public: void kill(); static void kill(int pid); - static Ptr forPid(int pid); + static ActorPtr forPid(int pid); /** * Wait for the actor to finish. @@ -254,11 +255,9 @@ public: protected: /** Returns the internal implementation of this actor */ - smx_process_t getImpl(); + smx_actor_t getImpl(); }; -using ActorPtr = Actor::Ptr; - /** @ingroup s4u_api * @brief Static methods working on the current actor (see @ref s4u::Actor) */ namespace this_actor { @@ -293,18 +292,23 @@ namespace this_actor { * * See \ref Comm for the full communication API (including non blocking communications). */ - XBT_PUBLIC(void*) recv(Mailbox &chan); + XBT_PUBLIC(void*) recv(MailboxPtr 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). */ - XBT_PUBLIC(void) send(Mailbox &chan, void*payload, size_t simulatedSize); + 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(); };