X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e64d6da8afc98eb8ea9838e48735e01e922863fc..7e42dd535dfc0d68de20fba4b9fc5e480b56c74b:/src/kernel/context/Context.cpp diff --git a/src/kernel/context/Context.cpp b/src/kernel/context/Context.cpp index 8a725349e8..63321ebb8d 100644 --- a/src/kernel/context/Context.cpp +++ b/src/kernel/context/Context.cpp @@ -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 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; -}