From f3348af357bc527d926d3dd454a9fa0840d812b3 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 20 Oct 2017 19:19:14 +0200 Subject: [PATCH] ContextBoost: make maestro_context_ private. --- src/kernel/context/ContextBoost.cpp | 6 +++--- src/kernel/context/ContextBoost.hpp | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index 46103930c6..2a68c8bcd9 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -31,12 +31,12 @@ namespace context { BoostContextFactory::BoostContextFactory() : ContextFactory("BoostContextFactory"), parallel_(SIMIX_context_is_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"); @@ -199,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(maestro_context_); + next_context = static_cast(BoostContext::getMaestro()); } SIMIX_context_set_current(static_cast(next_context)); BoostContext::swap(this, next_context); @@ -208,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 diff --git a/src/kernel/context/ContextBoost.hpp b/src/kernel/context/ContextBoost.hpp index 314b2a95f8..b0634592a9 100644 --- a/src/kernel/context/ContextBoost.hpp +++ b/src/kernel/context/ContextBoost.hpp @@ -37,7 +37,6 @@ protected: // static static uintptr_t threads_working_; static xbt_os_thread_key_t worker_id_key_; static unsigned long process_index_; - static BoostContext* maestro_context_; #if BOOST_VERSION < 105600 boost::context::fcontext_t* fc_ = nullptr; @@ -65,7 +64,13 @@ public: void stop() override; virtual void resume() = 0; + static BoostContext* getMaestro() { return maestro_context_; } + static void setMaestro(BoostContext* maestro) { maestro_context_ = maestro; } + friend BoostContextFactory; + +private: + static BoostContext* maestro_context_; }; class SerialBoostContext : public BoostContext { -- 2.20.1