if (SIMIX_is_maestro())
return std::forward<F>(code)();
- // If we are in the application, pass the code to the maestro which is
+ // If we are in the application, pass the code to the maestro which
// executes it for us and reports the result. We use a std::future which
// conveniently handles the success/failure value for us.
typedef typename std::result_of<F()>::type R;
- std::promise<R> promise;
+ simgrid::xbt::Result<R> result;
simcall_run_kernel([&]{
xbt_assert(SIMIX_is_maestro(), "Not in maestro");
- simgrid::xbt::fulfillPromise(promise, std::forward<F>(code));
+ simgrid::xbt::fulfillPromise(result, std::forward<F>(code));
});
- return promise.get_future().get();
+ return result.get();
}
class Context;
: Context(std::move(code), cleanup_func, process)
{}
- ~AttachContext();
+ ~AttachContext() override;
/** Called by the context when it is ready to give control
* to the maestro.