X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/60ffc444f2d5601980847857024a2719ddfefd68..5ed37babb2fa9097abe82df299c0aa259ed84d5a:/include/simgrid/s4u/Actor.hpp diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 7b8b4291b8..de7a22e978 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -188,8 +187,8 @@ class XBT_PUBLIC Actor : public xbt::Extendable { 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 +254,7 @@ public: static void on_destruction_cb(const std::function& cb) { on_destruction.connect(cb); } /** Create an actor from a @c std::function. - * 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 `. @endverbatim */ static ActorPtr create(const std::string& name, s4u::Host* host, const std::function& code); /** Create an actor, but don't start it yet. @@ -281,7 +280,7 @@ public: ActorPtr start(const std::function& code, std::vector args); - /** Create an actor from a callable thing. + /** Create an actor from a callable thing. * @verbatim embed:rst:inline See the :ref:`example `. @endverbatim */ template static ActorPtr create(const std::string& name, s4u::Host* host, F code) { @@ -290,7 +289,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 `. @endverbatim */ template `. @endverbatim */ static ActorPtr create(const std::string& name, s4u::Host* host, const std::string& function, std::vector args); @@ -322,7 +321,7 @@ public: static bool is_maestro(); /** Retrieves the name of that actor as a C++ string */ - const simgrid::xbt::string& get_name() const; + const std::string& get_name() const; /** Retrieves the name of that actor as a C string */ const char* get_cname() const; /** Retrieves the host on which that actor is running */ @@ -332,7 +331,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 +340,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.