From 92061e0bc62b9a2ef3bdc041e5e9fe716ada1120 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 17 Apr 2019 21:03:36 +0200 Subject: [PATCH] Inline Context::self(). --- src/kernel/context/Context.cpp | 10 +--------- src/kernel/context/Context.hpp | 6 ++++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/kernel/context/Context.cpp b/src/kernel/context/Context.cpp index 145e1e1cfe..37ef379473 100644 --- a/src/kernel/context/Context.cpp +++ b/src/kernel/context/Context.cpp @@ -22,15 +22,7 @@ ContextFactoryInitializer factory_initializer = nullptr; ContextFactory::~ContextFactory() = default; -static thread_local Context* smx_current_context = nullptr; -Context* Context::self() -{ - return smx_current_context; -} -void Context::set_current(Context* self) -{ - smx_current_context = self; -} +thread_local Context* Context::current_ = nullptr; void Context::declare_context(std::size_t size) { diff --git a/src/kernel/context/Context.hpp b/src/kernel/context/Context.hpp index 60504fafd0..c501de891e 100644 --- a/src/kernel/context/Context.hpp +++ b/src/kernel/context/Context.hpp @@ -43,6 +43,8 @@ protected: class XBT_PUBLIC Context { friend ContextFactory; + static thread_local Context* current_; + std::function code_; actor::ActorImpl* actor_ = nullptr; void declare_context(std::size_t size); @@ -65,9 +67,9 @@ public: // Retrieving the self() context /** @brief Retrives the current context of this thread */ - static Context* self(); + static Context* self() { return current_; } /** @brief Sets the current context of this thread */ - static void set_current(Context* self); + static void set_current(Context* self) { current_ = self; } }; class XBT_PUBLIC AttachContext : public Context { -- 2.20.1