Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mv s4u/mailbox.hpp s4u/Mailbox.hpp now that it's clean
[simgrid.git] / include / simgrid / s4u / Actor.hpp
index 34562df..95daaa2 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <xbt/base.h>
 #include <xbt/functional.hpp>
+#include <xbt/string.hpp>
 
 #include <simgrid/chrono.hpp>
 #include <simgrid/simix.h>
@@ -131,7 +132,7 @@ namespace s4u {
 /** @brief Simulation Agent (see \ref s4u_actor)*/
 XBT_PUBLIC_CLASS Actor {
   friend Mailbox;
-  friend simgrid::simix::Process;
+  friend simgrid::simix::ActorImpl;
   smx_process_t pimpl_ = nullptr;
 
   /** Wrap a (possibly non-copyable) single-use task into a `std::function` */
@@ -167,19 +168,18 @@ public:
     xbt_assert(actor != nullptr);
     SIMIX_process_unref(actor->pimpl_);
   }
-  using Ptr = boost::intrusive_ptr<Actor>;
 
   // ***** 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<void()> code);
+  static ActorPtr createActor(const char* name, s4u::Host *host, double killTime, std::function<void()> code);
 
-  static Ptr createActor(const char* name, s4u::Host *host, std::function<void()> code)
+  static ActorPtr createActor(const char* name, s4u::Host *host, std::function<void()> code)
   {
     return createActor(name, host, -1.0, std::move(code));
   }
@@ -195,17 +195,17 @@ public:
     // This constructor is enabled only if the call code(args...) is valid:
     typename = typename std::result_of<F(Args...)>::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<std::string> 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<std::string> args)
   {
     return createActor(name, host, -1.0, function, std::move(args));
@@ -217,11 +217,13 @@ public:
   //static Actor *byPid(int pid); not implemented
 
   /** Retrieves the name of that actor */
-  const char* getName();
+  simgrid::xbt::string getName();
   /** Retrieves the host on which that actor is running */
   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);
@@ -233,12 +235,13 @@ public:
   /** 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.
+   * SimGrid sometimes have issues when you kill actors that are currently communicating and such.
+   * We are working on it to fix the issues.
    */
   void kill();
 
   static void kill(int pid);
-  static Ptr forPid(int pid);
+  static ActorPtr forPid(int pid);
   
   /**
    * Wait for the actor to finish.
@@ -255,8 +258,6 @@ protected:
   smx_process_t getImpl();
 };
 
-using ActorPtr = Actor::Ptr;
-
 /** @ingroup s4u_api
  *  @brief Static methods working on the current actor (see @ref s4u::Actor) */
 namespace this_actor {
@@ -291,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();
 
 };