Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the Context::stop() and reduce duplication
[simgrid.git] / src / kernel / context / ContextThread.cpp
index 2b8c1d1d153467e504066c7294c55d3bef439cdd..f5a1f7a5e65982e31e4ba305bbfbc699b4236728 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,7 +16,7 @@
 #include <typeinfo>
 #include <utility>
 
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ker_context);
 
 namespace simgrid {
 namespace kernel {
@@ -60,13 +60,13 @@ void ThreadContextFactory::run_all()
 // ThreadContext
 
 ThreadContext::ThreadContext(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro)
-    : AttachContext(std::move(code), actor), is_maestro_(maestro)
+    : AttachContext(std::move(code), actormaestro)
 {
   /* If the user provided a function for the actor then use it */
   if (has_code()) {
     /* create and start the actor */
     this->thread_ = new std::thread(ThreadContext::wrapper, this);
-    /* wait the starting of the newly created actor */
+    /* wait the start of the newly created actor */
     this->end_.acquire();
   }
 
@@ -97,10 +97,8 @@ void ThreadContext::wrapper(ThreadContext* context)
 
   try {
     (*context)();
-    if (not context->is_maestro()) { // Just in case somebody detached maestro
-      context->Context::stop();
-      context->stop_hook();
-    }
+    if (not context->is_maestro()) // Just in case somebody detached maestro
+      context->stop();
   } catch (ForcefulKillException const&) {
     XBT_DEBUG("Caught a ForcefulKillException in Thread::wrapper");
     xbt_assert(not context->is_maestro(), "Maestro shall not receive ForcefulKillExceptions, even when detached.");
@@ -140,13 +138,6 @@ void ThreadContext::yield()
   this->end_.release();
 }
 
-void ThreadContext::stop()
-{
-  Context::stop();
-  stop_hook();
-  throw ForcefulKillException();
-}
-
 void ThreadContext::suspend()
 {
   this->yield();