Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitize the OOP of kernel::profile
[simgrid.git] / src / kernel / context / ContextThread.cpp
index 205e186..171e32e 100644 (file)
@@ -100,10 +100,12 @@ void *ThreadContext::wrapper(void *param)
 
   try {
     (*context)();
-    if (not context->is_maestro()) // Just in case somebody detached maestro
+    if (not context->is_maestro()) // Just in case somebody detached maestro
       context->Context::stop();
+      context->stop_hook();
+    }
   } catch (StopRequest const&) {
-    XBT_DEBUG("Caught a StopRequest");
+    XBT_DEBUG("Caught a StopRequest in Thread::wrapper");
     xbt_assert(not context->is_maestro(), "Maestro shall not receive StopRequests, even when detached.");
   } catch (simgrid::Exception const& e) {
     XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
@@ -116,6 +118,8 @@ void *ThreadContext::wrapper(void *param)
   stack.ss_flags = SS_DISABLE;
   sigaltstack(&stack, nullptr);
 #endif
+  XBT_DEBUG("Terminating");
+  Context::set_current(nullptr);
   return nullptr;
 }
 
@@ -144,6 +148,7 @@ void ThreadContext::yield()
 void ThreadContext::stop()
 {
   Context::stop();
+  stop_hook();
   throw StopRequest();
 }