Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the API between Engine and EngineImpl when registering functions
[simgrid.git] / src / s4u / s4u_Actor.cpp
index 4499d92..f2d5612 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. 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,6 +11,7 @@
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/VirtualMachine.hpp"
 #include "src/include/mc/mc.h"
+#include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/surf/HostImpl.hpp"
@@ -21,6 +22,9 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_actor, s4u, "S4U actors");
 
 namespace simgrid {
+
+template class xbt::Extendable<s4u::Actor>;
+
 namespace s4u {
 
 xbt::signal<void(Actor&)> s4u::Actor::on_creation;
@@ -70,7 +74,8 @@ ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::func
 ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::string& function,
                        std::vector<std::string> args)
 {
-  const simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
+  const simgrid::kernel::actor::ActorCodeFactory& factory =
+      simgrid::kernel::EngineImpl::get_instance()->get_function(function);
   return create(name, host, factory(std::move(args)));
 }
 
@@ -103,7 +108,7 @@ void Actor::join(double timeout)
       // The joined process is already finished, just wake up the issuer right away
       issuer->simcall_answer();
     } else {
-      smx_activity_t sync = issuer->join(target, timeout);
+      kernel::activity::ActivityImplPtr sync = issuer->join(target, timeout);
       sync->register_simcall(&issuer->simcall);
     }
   });
@@ -312,7 +317,7 @@ void sleep_for(double duration)
         issuer->simcall_answer();
         return;
       }
-      smx_activity_t sync = issuer->sleep(duration);
+      kernel::activity::ActivityImplPtr sync = issuer->sleep(duration);
       sync->register_simcall(&issuer->simcall);
     });
 
@@ -424,13 +429,6 @@ void suspend()
   kernel::actor::simcall_blocking<void>([self] { self->suspend(); });
 }
 
-void resume()
-{
-  kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
-  kernel::actor::simcall([self] { self->resume(); });
-  Actor::on_resume(*self->ciface());
-}
-
 void exit()
 {
   kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
@@ -466,11 +464,11 @@ sg_actor_t sg_actor_init(const char* name, sg_host_t host)
   return simgrid::s4u::Actor::init(name, host).get();
 }
 
-void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv)
+void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, const char* const* argv)
 {
-  simgrid::simix::ActorCode function;
+  simgrid::kernel::actor::ActorCode function;
   if (code)
-    function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
+    function = simgrid::xbt::wrap_main(code, argc, argv);
   actor->start(std::move(function));
 }