Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update warning message.
[simgrid.git] / src / s4u / s4u_Engine.cpp
index 72f7b18..7f74eef 100644 (file)
@@ -17,6 +17,7 @@
 #include "src/instr/instr_private.hpp"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/activity/CommImpl.hpp"
+#include "src/kernel/actor/ActorImpl.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/surf/network_interface.hpp"
 #include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
@@ -28,6 +29,8 @@
 XBT_LOG_NEW_CATEGORY(s4u, "Log channels of the S4U (Simgrid for you) interface");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_engine, s4u, "Logging specific to S4U (engine)");
 
+static simgrid::kernel::actor::ActorCode maestro_code;
+
 namespace simgrid {
 namespace s4u {
 xbt::signal<void()> Engine::on_platform_creation;
@@ -44,17 +47,19 @@ void Engine::initialize(int* argc, char** argv)
   Engine::instance_ = this;
   instr::init();
   pimpl->initialize(argc, argv);
-  SIMIX_global_init(argc, argv);
+  // Either create a new context with maestro or create
+  // a context object with the current context maestro):
+  kernel::actor::create_maestro(maestro_code);
 }
 
-Engine::Engine(std::string name) : pimpl(new kernel::EngineImpl(nullptr, nullptr))
+Engine::Engine(std::string name) : pimpl(new kernel::EngineImpl())
 {
   int argc   = 1;
   char* argv = &name[0];
   initialize(&argc, &argv);
 }
 
-Engine::Engine(int* argc, char** argv) : pimpl(new kernel::EngineImpl(argc, argv))
+Engine::Engine(int* argc, char** argv) : pimpl(new kernel::EngineImpl())
 {
   initialize(argc, argv);
 }
@@ -87,7 +92,7 @@ void Engine::shutdown()
 double Engine::get_clock()
 {
   if (MC_is_active() || MC_record_replay_is_active()) {
-    return MC_process_clock_get(SIMIX_process_self());
+    return MC_process_clock_get(kernel::actor::ActorImpl::self());
   } else {
     return surf_get_clock();
   }
@@ -96,7 +101,7 @@ double Engine::get_clock()
 void Engine::add_model(std::shared_ptr<kernel::resource::Model> model,
                        const std::vector<kernel::resource::Model*>& dependencies)
 {
-  simgrid::kernel::actor::simcall([this, &model, &dependencies] { pimpl->add_model(std::move(model), dependencies); });
+  kernel::actor::simcall([this, &model, &dependencies] { pimpl->add_model(std::move(model), dependencies); });
 }
 
 const std::vector<simgrid::kernel::resource::Model*>& Engine::get_all_models() const
@@ -456,6 +461,11 @@ Engine* Engine::set_default_comm_data_copy_callback(void (*callback)(kernel::act
 } // namespace s4u
 } // namespace simgrid
 
+double SIMIX_get_clock() // XBT_ATTRIB_DEPRECATED_v332
+{
+  return simgrid::s4u::Engine::get_clock();
+}
+
 /* **************************** Public C interface *************************** */
 void simgrid_init(int* argc, char** argv)
 {
@@ -491,3 +501,16 @@ int simgrid_get_actor_count() // XBT_ATTRIB_DEPRECATED_v330
 {
   return simgrid::s4u::Engine::get_instance()->get_actor_count();
 }
+
+void simgrid_set_maestro(void (*code)(void*), void* data)
+{
+#ifdef _WIN32
+  XBT_WARN("simgrid_set_maestro is believed to not work on windows. Please help us investigating this issue if "
+           "you need that feature");
+#endif
+  maestro_code = std::bind(code, data);
+}
+void SIMIX_set_maestro(void (*code)(void*), void* data) // XBT_ATTRIB_DEPRECATED_v333
+{
+  simgrid_set_maestro(code, data);
+}