From: Martin Quinson Date: Wed, 14 Aug 2019 00:03:56 +0000 (+0200) Subject: now, kernel::actor::simcall_blocking can return a value X-Git-Tag: v3.24~186 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5b576eb1c0ab1acba1ceb0808b3708efe8a26dc1?ds=sidebyside now, kernel::actor::simcall_blocking can return a value --- diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index 473bb3f4b1..9539451154 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -63,6 +63,9 @@ template typename std::result_of::type simcall(F&& code, mc::Simc * This is very similar to simcall() right above, but the calling actor will not get rescheduled until * actor->simcall_answer() is called explicitely. * + * Since the return value does not come from the lambda directly, its type cannot be guessed automatically and must + * be provided as template parameter. + * * This is meant for blocking actions. For example, locking a mutex is a blocking simcall. * First it's a simcall because that's obviously a modification of the world. Then, that's a blocking simcall because if * the mutex happens not to be free, the actor is added to a queue of actors in the mutex. Every mutex->unlock() takes @@ -72,7 +75,7 @@ template typename std::result_of::type simcall(F&& code, mc::Simc * * If your code never calls actor->simcall_answer() itself, the actor will never return from its simcall. */ -template typename std::result_of::type simcall_blocking(F&& code, mc::SimcallInspector* t = nullptr) +template R simcall_blocking(F&& code, mc::SimcallInspector* t = nullptr) { // If we are in the maestro, we take the fast path and execute the // code directly without simcall mashalling/unmarshalling/dispatch: @@ -82,7 +85,6 @@ template typename std::result_of::type simcall_blocking(F&& code, // 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; simgrid::xbt::Result result; simcall_run_blocking([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward(code)); }, t); return result.get(); diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 1840dfe657..9cfe9fa62d 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -97,7 +97,7 @@ void Actor::join(double timeout) { auto issuer = SIMIX_process_self(); auto target = pimpl_; - kernel::actor::simcall_blocking([issuer, target, timeout] { + kernel::actor::simcall_blocking([issuer, target, timeout] { if (target->finished_) { // The joined process is already finished, just wake up the issuer right away issuer->simcall_answer(); @@ -189,7 +189,7 @@ void Actor::suspend() auto issuer = SIMIX_process_self(); auto target = pimpl_; s4u::Actor::on_suspend(*this); - kernel::actor::simcall_blocking([issuer, target]() { + kernel::actor::simcall_blocking([issuer, target]() { target->suspend(issuer); if (target != issuer) { /* If we are suspending ourselves, then just do not finish the simcall now */ @@ -307,7 +307,7 @@ void sleep_for(double duration) kernel::actor::ActorImpl* issuer = SIMIX_process_self(); Actor::on_sleep(*issuer->ciface()); - kernel::actor::simcall_blocking([issuer, duration]() { + kernel::actor::simcall_blocking([issuer, duration]() { if (MC_is_active() || MC_record_replay_is_active()) { MC_process_clock_add(issuer, duration); issuer->simcall_answer();