X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3baaf982217fbc818965e8ed71c3ec91e96844d5..593f7525c1fbd75ab6c4f105f9f340401464fe0b:/src/kernel/context/ContextThread.cpp diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index 994935398f..205e1867da 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -75,9 +75,10 @@ ThreadContext::ThreadContext(std::function code, void_pfn_smxprocess_t c ThreadContext::~ThreadContext() { - if (this->thread_) /* If there is a thread (maestro don't have any), wait for its termination */ + if (this->thread_) { /* Maestro don't have any thread */ thread_->join(); - delete thread_; + delete thread_; + } } void *ThreadContext::wrapper(void *param) @@ -99,6 +100,8 @@ void *ThreadContext::wrapper(void *param) try { (*context)(); + if (not context->is_maestro()) // Just in case somebody detached maestro + context->Context::stop(); } catch (StopRequest const&) { XBT_DEBUG("Caught a StopRequest"); xbt_assert(not context->is_maestro(), "Maestro shall not receive StopRequests, even when detached."); @@ -106,9 +109,6 @@ void *ThreadContext::wrapper(void *param) XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get()); throw; } - if (not context->is_maestro()) // Just in case somebody detached maestro - context->Context::stop(); - // Signal to the caller (normally the maestro) that we have finished: context->yield();