X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cd05fcfa9ff6df9b054060937165d422a536bd99..24b63c987b1baf4e2fc2f68b00bd21c980eb8d6e:/include/simgrid/simix.hpp diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index 1122d16cfb..901081aa1b 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -24,6 +24,12 @@ XBT_PUBLIC(void) simcall_run_kernel(std::function const& code); +template inline +void simcall_run_kernel(F& f) +{ + simcall_run_kernel(std::function(std::ref(f))); +} + namespace simgrid { namespace simix { @@ -41,16 +47,16 @@ typename std::result_of::type kernel(F&& code) if (SIMIX_is_maestro()) return std::forward(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::type R; - std::promise promise; + simgrid::xbt::Result result; simcall_run_kernel([&]{ xbt_assert(SIMIX_is_maestro(), "Not in maestro"); - simgrid::xbt::fulfillPromise(promise, std::forward(code)); + simgrid::xbt::fulfillPromise(result, std::forward(code)); }); - return promise.get_future().get(); + return result.get(); } class Context;