-static void smx_ctx_boost_wrapper(std::intptr_t arg)
-{
- BoostContext* context = (BoostContext*) arg;
- (*context)();
- context->stop();
-}
-
-BoostContext::BoostContext(std::function<void()> code,
- void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
- : Context(std::move(code), cleanup_func, process)
-{
-
- /* if the user provided a function for the process then use it,
- otherwise it is the context for maestro */
- if (has_code()) {
- this->stack_ = SIMIX_context_stack_new();
- // 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 = (char*) this->stack_ + smx_context_usable_stack_size - 1;
- #else
- void* stack = this->stack_;
- #endif
- this->fc_ = boost::context::make_fcontext(
- stack,
- smx_context_usable_stack_size,
- smx_ctx_boost_wrapper);