X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/21b66417dc664ea6cba398553a62beb3a9270f75..f9d7b35c174d52377ef297f786129e0340ae0778:/include/simgrid/simix.hpp diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index 1829bad3a3..5fbc4d5fd8 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -13,13 +13,33 @@ #include #include #include +#include +#include #include #include +XBT_PUBLIC(void) simcall_run_kernel(std::function const& code); + namespace simgrid { namespace simix { +template +typename std::result_of::type kernel(F&& code) +{ + typedef typename std::result_of::type R; + std::promise promise; + simcall_run_kernel([&]{ + try { + promise.set_value(code()); + } + catch(...) { + promise.set_exception(std::current_exception()); + } + }); + return promise.get_future().get(); +} + class Context; class ContextFactory;