Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill the now useless ParallelRawContext and ParallelBoostContext
[simgrid.git] / src / kernel / context / Context.cpp
index 8a72534..63321eb 100644 (file)
@@ -34,7 +34,7 @@ ContextFactoryInitializer factory_initializer = nullptr;
 
 ContextFactory::~ContextFactory() = default;
 
-static thread_local smx_context_t smx_current_context;
+static thread_local smx_context_t smx_current_context = nullptr;
 Context* Context::self()
 {
   return smx_current_context;
@@ -77,7 +77,11 @@ Context::Context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func,
     set_current(this);
 }
 
-Context::~Context() = default;
+Context::~Context()
+{
+  if (self() == this)
+    set_current(nullptr);
+}
 
 void Context::stop()
 {
@@ -99,12 +103,3 @@ void SIMIX_context_runall()
 {
   simix_global->context_factory->run_all();
 }
-
-/** @brief returns the current running context */
-smx_context_t SIMIX_context_self()
-{
-  if (simix_global && simix_global->context_factory)
-    return simgrid::kernel::context::Context::self();
-  else
-    return nullptr;
-}