Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of simix_global and smx_private.hpp
[simgrid.git] / src / kernel / context / ContextThread.cpp
index 2a3b815..7cb10dd 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "simgrid/Exception.hpp"
 #include "src/internal_config.h" /* loads context system definitions */
-#include "src/simix/smx_private.hpp"
+#include "src/kernel/EngineImpl.hpp"
 #include "xbt/function_types.h"
 #include "xbt/xbt_modinter.h" /* prototype of os thread module's init/exit in XBT */
 
@@ -156,7 +156,7 @@ void ThreadContext::suspend()
 void ThreadContext::attach_start()
 {
   // We're breaking the layers here by depending on the upper layer:
-  auto* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
+  auto* maestro = static_cast<ThreadContext*>(EngineImpl::get_instance()->get_maestro()->context_.get());
   maestro->begin_.release();
   xbt_assert(not this->is_maestro());
   this->start();
@@ -167,7 +167,7 @@ void ThreadContext::attach_stop()
   xbt_assert(not this->is_maestro());
   this->yield();
 
-  auto* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
+  auto* maestro = static_cast<ThreadContext*>(EngineImpl::get_instance()->get_maestro()->context_.get());
   maestro->end_.acquire();
 
   Context::set_current(nullptr);
@@ -177,7 +177,8 @@ void ThreadContext::attach_stop()
 
 void SerialThreadContext::run_all()
 {
-  for (smx_actor_t const& actor : simix_global->actors_to_run) {
+  const auto& to_run = EngineImpl::get_instance()->get_actors_to_run();
+  for (smx_actor_t const& actor : to_run) {
     XBT_DEBUG("Handling %p", actor);
     auto* context = static_cast<ThreadContext*>(actor->context_.get());
     context->release();
@@ -202,9 +203,11 @@ void ParallelThreadContext::finalize()
 
 void ParallelThreadContext::run_all()
 {
-  for (smx_actor_t const& actor : simix_global->actors_to_run)
+  const auto& to_release = EngineImpl::get_instance()->get_actors_to_run();
+  for (smx_actor_t const& actor : to_release)
     static_cast<ThreadContext*>(actor->context_.get())->release();
-  for (smx_actor_t const& actor : simix_global->actors_to_run)
+  const auto& to_wait = EngineImpl::get_instance()->get_actors_to_run();
+  for (smx_actor_t const& actor : to_wait)
     static_cast<ThreadContext*>(actor->context_.get())->wait();
 }