Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use const reference for parameter of type ActorCodeFactory.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 4 Feb 2020 20:21:19 +0000 (21:21 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 5 Feb 2020 10:13:58 +0000 (11:13 +0100)
include/simgrid/s4u/Engine.hpp
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/s4u/s4u_Engine.cpp

index e2e0c86..c35db1d 100644 (file)
@@ -59,9 +59,9 @@ public:
   XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_default(
       int (*code)(int, char**));
   void register_default(void (*code)(int, char**));
-  void register_default(kernel::actor::ActorCodeFactory factory);
+  void register_default(const kernel::actor::ActorCodeFactory& factory);
 
-  void register_function(const std::string& name, kernel::actor::ActorCodeFactory factory);
+  void register_function(const std::string& name, const kernel::actor::ActorCodeFactory& factory);
   template <class F> void register_actor(const std::string& name)
   {
     register_function(name, [](std::vector<std::string> args) {
index b0ca669..28f993c 100644 (file)
@@ -49,11 +49,11 @@ void EngineImpl::load_deployment(const std::string& file)
   surf_parse_close();
 }
 
-void EngineImpl::register_function(const std::string& name, actor::ActorCodeFactory code)
+void EngineImpl::register_function(const std::string& name, const actor::ActorCodeFactory& code)
 {
   registered_functions[name] = code;
 }
-void EngineImpl::register_default(actor::ActorCodeFactory code)
+void EngineImpl::register_default(const actor::ActorCodeFactory& code)
 {
   default_function = code;
 }
index 5712dc9..f619bf6 100644 (file)
@@ -31,8 +31,8 @@ public:
   virtual ~EngineImpl();
 
   void load_deployment(const std::string& file);
-  void register_function(const std::string& name, actor::ActorCodeFactory code);
-  void register_default(actor::ActorCodeFactory code);
+  void register_function(const std::string& name, const actor::ActorCodeFactory& code);
+  void register_default(const actor::ActorCodeFactory& code);
 
   routing::NetZoneImpl* netzone_root_ = nullptr;
   static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; }
index bf7f744..c30e3ef 100644 (file)
@@ -120,14 +120,14 @@ void Engine::register_default(void (*code)(int, char**))
 {
   register_default([code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
 }
-void Engine::register_default(kernel::actor::ActorCodeFactory code)
+void Engine::register_default(const kernel::actor::ActorCodeFactory& code)
 {
-  simgrid::kernel::actor::simcall([this, code]() { pimpl->register_default(code); });
+  simgrid::kernel::actor::simcall([this, &code]() { pimpl->register_default(code); });
 }
 
-void Engine::register_function(const std::string& name, kernel::actor::ActorCodeFactory code)
+void Engine::register_function(const std::string& name, const kernel::actor::ActorCodeFactory& code)
 {
-  simgrid::kernel::actor::simcall([this, name, code]() { pimpl->register_function(name, code); });
+  simgrid::kernel::actor::simcall([this, name, &code]() { pimpl->register_function(name, code); });
 }
 
 /** Load a deployment file and launch the actors that it contains