Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to chain some setters on actors
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 27 Feb 2022 09:23:47 +0000 (10:23 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 27 Feb 2022 09:23:47 +0000 (10:23 +0100)
include/simgrid/s4u/Actor.hpp
src/s4u/s4u_Actor.cpp

index 017a8a7..60f7515 100644 (file)
@@ -308,7 +308,7 @@ public:
 
   // ***** Methods *****
   /** This actor will be automatically terminated when the last non-daemon actor finishes **/
-  void daemonize();
+  Actor* daemonize();
 
   /** Returns whether or not this actor has been daemonized or not **/
   bool is_daemon() const;
@@ -335,7 +335,7 @@ public:
   bool is_suspended() const;
 
   /** If set to true, the actor will automatically restart when its host reboots */
-  void set_auto_restart(bool autorestart);
+  Actor* set_auto_restart(bool autorestart);
 
   /** 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.
index bc9956a..576f0b1 100644 (file)
@@ -122,7 +122,7 @@ void Actor::join(double timeout) const
   });
 }
 
-void Actor::set_auto_restart(bool autorestart)
+Actor* Actor::set_auto_restart(bool autorestart)
 {
   kernel::actor::simcall([this, autorestart]() {
     xbt_assert(autorestart && not pimpl_->has_to_auto_restart()); // FIXME: handle all cases
@@ -132,6 +132,7 @@ void Actor::set_auto_restart(bool autorestart)
     XBT_DEBUG("Adding %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname());
     pimpl_->get_host()->get_impl()->add_actor_at_boot(arg);
   });
+  return this;
 }
 
 void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun) const
@@ -160,9 +161,10 @@ s4u::Host* Actor::get_host() const
   return this->pimpl_->get_host();
 }
 
-void Actor::daemonize()
+Actor* Actor::daemonize()
 {
   kernel::actor::simcall([this]() { pimpl_->daemonize(); });
+  return this;
 }
 
 bool Actor::is_daemon() const