Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ContextBoost: make maestro_context_ private.
[simgrid.git] / src / kernel / context / ContextBoost.cpp
index 6a8beb7..2a68c8b 100644 (file)
@@ -29,15 +29,14 @@ namespace context {
 // BoostContextFactory
 
 BoostContextFactory::BoostContextFactory()
-  : ContextFactory("BoostContextFactory")
+    : ContextFactory("BoostContextFactory"), parallel_(SIMIX_context_is_parallel())
 {
-  BoostContext::parallel_ = SIMIX_context_is_parallel();
-  if (BoostContext::parallel_) {
+  BoostContext::setMaestro(nullptr);
+  if (parallel_) {
 #if HAVE_THREAD_CONTEXTS
     BoostContext::parmap_ = nullptr;
     BoostContext::workers_context_.clear();
     BoostContext::workers_context_.resize(SIMIX_context_get_nthreads(), nullptr);
-    BoostContext::maestro_context_ = nullptr;
     xbt_os_thread_key_create(&BoostContext::worker_id_key_);
 #else
     xbt_die("No thread support for parallel context execution");
@@ -58,7 +57,7 @@ smx_context_t BoostContextFactory::create_context(std::function<void()> code, vo
                                                   smx_actor_t process)
 {
 #if HAVE_THREAD_CONTEXTS
-  if (BoostContext::parallel_)
+  if (parallel_)
     return this->new_context<ParallelBoostContext>(std::move(code), cleanup_func, process);
 #endif
 
@@ -68,7 +67,7 @@ smx_context_t BoostContextFactory::create_context(std::function<void()> code, vo
 void BoostContextFactory::run_all()
 {
 #if HAVE_THREAD_CONTEXTS
-  if (BoostContext::parallel_) {
+  if (parallel_) {
     BoostContext::threads_working_ = 0;
     if (not BoostContext::parmap_)
       BoostContext::parmap_ =
@@ -94,7 +93,6 @@ void BoostContextFactory::run_all()
 
 // BoostContext
 
-bool BoostContext::parallel_                             = false;
 simgrid::xbt::Parmap<smx_actor_t>* BoostContext::parmap_ = nullptr;
 uintptr_t BoostContext::threads_working_                 = 0;
 xbt_os_thread_key_t BoostContext::worker_id_key_;
@@ -201,7 +199,7 @@ void SerialBoostContext::suspend()
   } else {
     /* all processes were run, return to maestro */
     XBT_DEBUG("No more process to run");
-    next_context = static_cast<SerialBoostContext*>(maestro_context_);
+    next_context = static_cast<SerialBoostContext*>(BoostContext::getMaestro());
   }
   SIMIX_context_set_current(static_cast<smx_context_t>(next_context));
   BoostContext::swap(this, next_context);
@@ -210,7 +208,7 @@ void SerialBoostContext::suspend()
 void SerialBoostContext::resume()
 {
   SIMIX_context_set_current(this);
-  BoostContext::swap(maestro_context_, this);
+  BoostContext::swap(BoostContext::getMaestro(), this);
 }
 
 // ParallelBoostContext