Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
transparent cleanups around simcalls mechanism
[simgrid.git] / src / kernel / context / ContextBoost.cpp
index 6153c41..afdb933 100644 (file)
@@ -15,17 +15,15 @@ namespace kernel {
 namespace context {
 
 // BoostContextFactory
-smx_context_t BoostContextFactory::create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func,
-                                                  smx_actor_t process)
+BoostContext* BoostContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor)
 {
-  return this->new_context<BoostContext>(std::move(code), cleanup_func, process, this);
+  return this->new_context<BoostContext>(std::move(code), actor, this);
 }
 
 // BoostContext
 
-BoostContext::BoostContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor,
-                           SwappedContextFactory* factory)
-    : SwappedContext(std::move(code), cleanup_func, actor, factory)
+BoostContext::BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
+    : SwappedContext(std::move(code), actor, factory)
 {
 
   /* if the user provided a function for the process then use it, otherwise it is the context for maestro */
@@ -33,14 +31,14 @@ BoostContext::BoostContext(std::function<void()> code, void_pfn_smxprocess_t cle
     /* We need to pass the bottom of the stack to make_fcontext,
        depending on the stack direction it may be the lower or higher address: */
 #if PTH_STACKGROWTH == -1
-    void* stack = static_cast<char*>(get_stack()) + smx_context_usable_stack_size;
+    unsigned char* stack = get_stack() + smx_context_stack_size;
 #else
-    void* stack = get_stack();
+    unsigned char* stack = get_stack();
 #endif
 #if BOOST_VERSION < 106100
-    this->fc_ = boost::context::make_fcontext(stack, smx_context_usable_stack_size, BoostContext::wrapper);
+    this->fc_ = boost::context::make_fcontext(stack, smx_context_stack_size, BoostContext::wrapper);
 #else
-    this->fc_ = boost::context::detail::make_fcontext(stack, smx_context_usable_stack_size, BoostContext::wrapper);
+    this->fc_ = boost::context::detail::make_fcontext(stack, smx_context_stack_size, BoostContext::wrapper);
 #endif
 
   } else {
@@ -71,10 +69,10 @@ void BoostContext::wrapper(BoostContext::arg_type arg)
   try {
     (*context)();
     context->Context::stop();
-  } catch (StopRequest const&) {
-    XBT_DEBUG("Caught a StopRequest");
+  } catch (ForcefulKillException const&) {
+    XBT_DEBUG("Caught a ForcefulKillException");
   } catch (simgrid::Exception const& e) {
-    XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
+    XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
     throw;
   }
   ASAN_ONLY(context->asan_stop_ = true);
@@ -105,4 +103,6 @@ XBT_PRIVATE ContextFactory* boost_factory()
   XBT_VERB("Using Boost contexts. Welcome to the 21th century.");
   return new BoostContextFactory();
 }
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid