Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sort include lists according to clang-format.
[simgrid.git] / src / kernel / context / ContextRaw.cpp
index 53726aa..1df1de7 100644 (file)
@@ -7,8 +7,8 @@
 
 #include "xbt/parmap.hpp"
 
-#include "src/simix/smx_private.h"
 #include "mc/mc.h"
+#include "src/simix/smx_private.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
 
@@ -270,7 +270,7 @@ RawContextFactory::RawContextFactory()
     raw_workers_context = xbt_new(RawContext*, nthreads);
     raw_maestro_context = nullptr;
 #endif
-    // TODO, if(SIMIX_context_get_parallel_threshold() > 1) => choose dynamically
+    // TODO: choose dynamically when SIMIX_context_get_parallel_threshold() > 1
   }
 }
 
@@ -291,8 +291,13 @@ RawContext* RawContextFactory::create_context(std::function<void()> code,
 void RawContext::wrapper(void* arg)
 {
   RawContext* context = static_cast<RawContext*>(arg);
-  (*context)();
-  context->stop();
+  try {
+    (*context)();
+    context->Context::stop();
+  } catch (StopRequest const&) {
+    XBT_DEBUG("Caught a StopRequest");
+  }
+  context->suspend();
 }
 
 RawContext::RawContext(std::function<void()> code,
@@ -323,7 +328,7 @@ RawContext::~RawContext()
 void RawContext::stop()
 {
   Context::stop();
-  this->suspend();
+  throw StopRequest();
 }
 
 void RawContextFactory::run_all()