Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove features marked with XBT_ATTRIB_DEPRECATED_v325.
[simgrid.git] / include / simgrid / s4u / Actor.hpp
index 1dc179f..0eda16d 100644 (file)
@@ -6,15 +6,18 @@
 #ifndef SIMGRID_S4U_ACTOR_HPP
 #define SIMGRID_S4U_ACTOR_HPP
 
-#include <functional>
-#include <map> // deprecated wrappers
+#include <simgrid/forward.h>
+
 #include <simgrid/chrono.hpp>
-#include <unordered_map>
 #include <xbt/Extendable.hpp>
 #include <xbt/functional.hpp>
 #include <xbt/signal.hpp>
 #include <xbt/string.hpp>
 
+#include <functional>
+#include <map> // deprecated wrappers
+#include <unordered_map>
+
 namespace simgrid {
 namespace s4u {
 
@@ -121,12 +124,14 @@ namespace s4u {
 
 /** @brief Simulation Agent */
 class XBT_PUBLIC Actor : public xbt::Extendable<Actor> {
+#ifndef DOXYGEN
   friend Exec;
   friend Mailbox;
   friend kernel::actor::ActorImpl;
   friend kernel::activity::MailboxImpl;
 
   kernel::actor::ActorImpl* const pimpl_;
+#endif
 
   explicit Actor(smx_actor_t pimpl) : pimpl_(pimpl) {}
 
@@ -139,12 +144,13 @@ public:
   // ***** Reference count *****
   friend XBT_PUBLIC void intrusive_ptr_add_ref(Actor * actor);
   friend XBT_PUBLIC void intrusive_ptr_release(Actor * actor);
+  int get_refcount();
 
   // ***** Actor creation *****
   /** Retrieve a reference to myself */
   static Actor* self();
 
-  /** Signal to others that a new actor has been created **/
+  /** Fired when a new actor has been created **/
   static xbt::signal<void(Actor&)> on_creation;
   /** Signal to others that an actor has been suspended**/
   static xbt::signal<void(Actor const&)> on_suspend;
@@ -158,9 +164,15 @@ public:
   static xbt::signal<void(Actor const&)> on_migration_start;
   /** Signal to others that an actor is has been migrated to another host **/
   static xbt::signal<void(Actor const&)> on_migration_end;
-  /** Signal indicating that an actor is about to disappear.
-   *  This signal is fired for any dying actor, which is mostly useful when designing plugins and extensions. If you
-   *  want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
+  /** Signal indicating that an actor terminated its code.
+   *  The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore.
+   *  If you want to free extra data when the actor's destructor is called, use Actor::on_destruction.
+   *  If you want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
+  static xbt::signal<void(Actor const&)> on_termination;
+  /** Signal indicating that an actor is about to disappear (its destructor was called).
+   *  This signal is fired for any destructed actor, which is mostly useful when designing plugins and extensions.
+   *  If you want to react to the end of the actor's code, use Actor::on_termination instead.
+   *  If you want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
   static xbt::signal<void(Actor const&)> on_destruction;
 
   /** Create an actor from a std::function<void()>
@@ -289,17 +301,10 @@ public:
   kernel::actor::ActorImpl* get_impl() const { return pimpl_; }
 
   /** Retrieve the property value (or nullptr if not set) */
-  std::unordered_map<std::string, std::string>*
+  const std::unordered_map<std::string, std::string>*
   get_properties() const; // FIXME: do not export the map, but only the keys or something
   const char* get_property(const std::string& key) const;
   void set_property(const std::string& key, const std::string& value);
-
-#ifndef DOXYGEN
-  XBT_ATTRIB_DEPRECATED_v325("Please use Actor::on_exit(fun) instead") void on_exit(
-      const std::function<void(int, void*)>& fun, void* data);
-
-  XBT_ATTRIB_DEPRECATED_v325("Please use Actor::by_pid(pid).kill() instead") static void kill(aid_t pid);
-#endif
 };
 
 /** @ingroup s4u_api
@@ -308,10 +313,10 @@ namespace this_actor {
 
 XBT_PUBLIC bool is_maestro();
 
-/** Block the current actor sleeping for that amount of seconds (may throw hostFailure) */
+/** Block the current actor sleeping for that amount of seconds */
 XBT_PUBLIC void sleep_for(double duration);
-/** Block the current actor sleeping until the specified timestamp (may throw hostFailure) */
-XBT_PUBLIC void sleep_until(double timeout);
+/** Block the current actor sleeping until the specified timestamp */
+XBT_PUBLIC void sleep_until(double wakeup_time);
 
 template <class Rep, class Period> inline void sleep_for(std::chrono::duration<Rep, Period> duration)
 {
@@ -319,9 +324,9 @@ template <class Rep, class Period> inline void sleep_for(std::chrono::duration<R
   this_actor::sleep_for(seconds.count());
 }
 
-template <class Duration> inline void sleep_until(const SimulationTimePoint<Duration>& timeout_time)
+template <class Duration> inline void sleep_until(const SimulationTimePoint<Duration>& wakeup_time)
 {
-  auto timeout_native = std::chrono::time_point_cast<SimulationClockDuration>(timeout_time);
+  auto timeout_native = std::chrono::time_point_cast<SimulationClockDuration>(wakeup_time);
   this_actor::sleep_until(timeout_native.time_since_epoch().count());
 }
 
@@ -396,15 +401,6 @@ XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std
 XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
                                  const std::vector<double>& bytes_amounts, double timeout);
 
-#ifndef DOXYGEN
-XBT_ATTRIB_DEPRECATED_v325("Please use std::vectors as parameters") XBT_PUBLIC
-    void parallel_execute(int host_nb, s4u::Host* const* host_list, const double* flops_amount,
-                          const double* bytes_amount);
-XBT_ATTRIB_DEPRECATED_v325("Please use std::vectors as parameters") XBT_PUBLIC
-    void parallel_execute(int host_nb, s4u::Host* const* host_list, const double* flops_amount,
-                          const double* bytes_amount, double timeout);
-#endif
-
 XBT_PUBLIC ExecPtr exec_init(double flops_amounts);
 XBT_PUBLIC ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
                              const std::vector<double>& bytes_amounts);
@@ -422,7 +418,7 @@ XBT_PUBLIC std::string get_name();
 /** @brief Returns the name of the current actor as a C string. */
 XBT_PUBLIC const char* get_cname();
 
-/** @brief Returns the name of the host on which the curret actor is running. */
+/** @brief Returns the name of the host on which the current actor is running. */
 XBT_PUBLIC Host* get_host();
 
 /** @brief Suspend the current actor, that is blocked until resume()ed by another actor. */
@@ -457,14 +453,6 @@ XBT_PUBLIC void on_exit(const std::function<void(bool)>& fun);
 XBT_PUBLIC void migrate(Host* new_host);
 
 /** @} */
-
-#ifndef DOXYGEN
-XBT_ATTRIB_DEPRECATED_v325("Please use std::function<void(bool)> for first parameter.") XBT_PUBLIC
-    void on_exit(const std::function<void(int, void*)>& fun, void* data);
-
-/** @deprecated See this_actor::exit() */
-XBT_ATTRIB_DEPRECATED_v324("Please use this_actor::exit()") XBT_PUBLIC void kill();
-#endif
 }