From 285721a10666864ff257d2709094ece7dcccc879 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 20 Oct 2017 19:13:29 +0200 Subject: [PATCH] ContextBoost: move parallel_ from BoostContext to BoostContextFactory. --- src/kernel/context/ContextBoost.cpp | 10 ++++------ src/kernel/context/ContextBoost.hpp | 4 +++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index 6a8beb7c37..46103930c6 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -29,10 +29,9 @@ namespace context { // BoostContextFactory BoostContextFactory::BoostContextFactory() - : ContextFactory("BoostContextFactory") + : ContextFactory("BoostContextFactory"), parallel_(SIMIX_context_is_parallel()) { - BoostContext::parallel_ = SIMIX_context_is_parallel(); - if (BoostContext::parallel_) { + if (parallel_) { #if HAVE_THREAD_CONTEXTS BoostContext::parmap_ = nullptr; BoostContext::workers_context_.clear(); @@ -58,7 +57,7 @@ smx_context_t BoostContextFactory::create_context(std::function code, vo smx_actor_t process) { #if HAVE_THREAD_CONTEXTS - if (BoostContext::parallel_) + if (parallel_) return this->new_context(std::move(code), cleanup_func, process); #endif @@ -68,7 +67,7 @@ smx_context_t BoostContextFactory::create_context(std::function 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* BoostContext::parmap_ = nullptr; uintptr_t BoostContext::threads_working_ = 0; xbt_os_thread_key_t BoostContext::worker_id_key_; diff --git a/src/kernel/context/ContextBoost.hpp b/src/kernel/context/ContextBoost.hpp index a816fe62ba..314b2a95f8 100644 --- a/src/kernel/context/ContextBoost.hpp +++ b/src/kernel/context/ContextBoost.hpp @@ -32,7 +32,6 @@ class BoostContextFactory; /** @brief Userspace context switching implementation based on Boost.Context */ class BoostContext : public Context { protected: // static - static bool parallel_; static simgrid::xbt::Parmap* parmap_; static std::vector workers_context_; static uintptr_t threads_working_; @@ -97,6 +96,9 @@ public: ~BoostContextFactory() override; Context* create_context(std::function code, void_pfn_smxprocess_t, smx_actor_t process) override; void run_all() override; + +private: + bool parallel_; }; }}} // namespace -- 2.20.1