Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get access to Exec thread count
[simgrid.git] / include / simgrid / s4u / Actor.hpp
index 7b8b4291b8085de0e62c4cbbc55e9b703827fe4b..b75614c5f1442fece5ecdf4429c7c1731010b88e 100644 (file)
@@ -188,8 +188,8 @@ class XBT_PUBLIC Actor : public xbt::Extendable<Actor> {
   friend Mailbox;
   friend kernel::actor::ActorImpl;
   friend kernel::activity::MailboxImpl;
-  friend void this_actor::sleep_for(double);
-  friend void this_actor::suspend();
+  friend XBT_PUBLIC void this_actor::sleep_for(double);
+  friend XBT_PUBLIC void this_actor::suspend();
 
   kernel::actor::ActorImpl* const pimpl_;
 #endif
@@ -255,7 +255,7 @@ public:
   static void on_destruction_cb(const std::function<void(Actor const&)>& cb) { on_destruction.connect(cb); }
 
   /** Create an actor from a @c std::function<void()>.
-   *  If the actor is restarted, it gets a fresh copy of the function. 
+   *  If the actor is restarted, it gets a fresh copy of the function.
    *  @verbatim embed:rst:inline See the :ref:`example <s4u_ex_actors_create>`. @endverbatim */
   static ActorPtr create(const std::string& name, s4u::Host* host, const std::function<void()>& code);
   /** Create an actor, but don't start it yet.
@@ -281,7 +281,7 @@ public:
 
   ActorPtr start(const std::function<void()>& code, std::vector<std::string> args);
 
-  /** Create an actor from a callable thing. 
+  /** Create an actor from a callable thing.
    *  @verbatim embed:rst:inline See the :ref:`example <s4u_ex_actors_create>`. @endverbatim */
   template <class F> static ActorPtr create(const std::string& name, s4u::Host* host, F code)
   {
@@ -290,7 +290,7 @@ public:
 
   /** Create an actor using a callable thing and its arguments.
    *
-   * Note that the arguments will be copied, so move-only parameters are forbidden. 
+   * Note that the arguments will be copied, so move-only parameters are forbidden.
    * @verbatim embed:rst:inline See the :ref:`example <s4u_ex_actors_create>`. @endverbatim */
 
   template <class F, class... Args,
@@ -304,7 +304,7 @@ public:
     return create(name, host, std::bind(std::move(code), std::move(args)...));
   }
 
-  /** Create actor from function name and a vector of strings as arguments. 
+  /** Create actor from function name and a vector of strings as arguments.
    *  @verbatim embed:rst:inline See the :ref:`example <s4u_ex_actors_create>`. @endverbatim */
   static ActorPtr create(const std::string& name, s4u::Host* host, const std::string& function,
                          std::vector<std::string> args);
@@ -332,7 +332,7 @@ public:
   /** Retrieves the actor ID of that actor's creator */
   aid_t get_ppid() const;
 
-  /** Suspend an actor, that is blocked until resumeed by another actor */
+  /** Suspend an actor, that is blocked until resumed by another actor. */
   void suspend();
 
   /** Resume an actor that was previously suspended */
@@ -341,8 +341,20 @@ public:
   /** Returns true if the actor is suspended. */
   bool is_suspended() const;
 
-  /** If set to true, the actor will automatically restart when its host reboots */
+  /** If set to true, the actor will automatically restart when its host reboots.
+   *
+   * Some elements of the actor are remembered over reboots: name, host, properties, the on_exit functions, whether it
+   * is daemonized and whether it should automatically restart when its host reboots. Note that the state after reboot
+   * is the one when set_auto_restart() is called.
+   *
+   * If you daemonize your actor after marking it auto_restart, then the new actor after rebooot will not be a daemon.
+   *
+   * The on_exit functions are the one defined when the actor dies, not the ones given when it was marked auto_restart
+   * (sorry for the inconsistency -- speak to us if it's too hard to bear).
+   */
   Actor* set_auto_restart(bool autorestart = true);
+  /** Returns the number of reboots that this actor did. Before the first reboot, this function returns 0. */
+  int get_restart_count() const;
 
   /** Add a function to the list of "on_exit" functions for the current actor. The on_exit functions are the functions
    * executed when your actor is killed. You should use them to free the data used by your actor.