- /* Tell the maestro we are starting, and wait for its green light */
- xbt_os_sem_release(context->end_);
-
- xbt_os_sem_acquire(context->begin_);
- if (smx_ctx_thread_sem) /* parallel run */
- xbt_os_sem_acquire(smx_ctx_thread_sem);
-
- (*context)();
- context->stop();
-
- return nullptr;
-}
-
-void *ThreadContext::maestro_wrapper(void *param)
-{
- ThreadContext* context = static_cast<ThreadContext*>(param);
-
-#ifndef WIN32
- /* Install alternate signal stack, for SIGSEGV handler. */
- stack_t stack;
- stack.ss_sp = sigsegv_stack;
- stack.ss_size = sizeof sigsegv_stack;
- stack.ss_flags = 0;
- sigaltstack(&stack, nullptr);
-#endif
- /* Tell the caller we are starting */
- xbt_os_sem_release(context->end_);
-
- // Wait for the caller to give control back to us:
- xbt_os_sem_acquire(context->begin_);
- (*context)();
+ // Tell the caller (normally the maestro) we are starting, and wait for its green light
+ context->end_.release();
+ context->start();
+
+ try {
+ (*context)();
+ } catch (StopRequest const&) {
+ XBT_DEBUG("Caught a StopRequest");
+ 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());
+ throw;
+ }
+ if (not context->is_maestro()) // Just in case somebody detached maestro
+ context->Context::stop();