Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Inline Context::self().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 17 Apr 2019 19:03:36 +0000 (21:03 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 17 Apr 2019 19:39:17 +0000 (21:39 +0200)
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp

index 145e1e1..37ef379 100644 (file)
@@ -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)
 {
index 60504fa..c501de8 100644 (file)
@@ -43,6 +43,8 @@ protected:
 class XBT_PUBLIC Context {
   friend ContextFactory;
 
+  static thread_local Context* current_;
+
   std::function<void()> 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 {