From: Takishipp Date: Tue, 24 Oct 2017 14:32:11 +0000 (+0200) Subject: suggested solution tu use simix through a function X-Git-Tag: v3.18~227^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c4f055b70f68bb462cefb9e4ecea8a3d5320dd0d?hp=932d38721fb6e00fb85a133753926429d57b6939 suggested solution tu use simix through a function --- diff --git a/examples/s4u/actor-yield/s4u-actor-yield.cpp b/examples/s4u/actor-yield/s4u-actor-yield.cpp index b5a5d92f01..6e79dc6c6b 100644 --- a/examples/s4u/actor-yield/s4u-actor-yield.cpp +++ b/examples/s4u/actor-yield/s4u-actor-yield.cpp @@ -28,8 +28,9 @@ public: } void operator()() { + simgrid::s4u::ActorPtr actor; for (int i = 0; i < number_of_yields; i++) - simgrid::simix::kernelImmediate([] { /* do nothing*/ }); + actor->yield(); XBT_INFO("I yielded %ld times. Goodbye now!", number_of_yields); } }; diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index eef1611123..b4e58c9ece 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -218,6 +218,8 @@ public: /** Resume a suspended process by resuming the task on which it was waiting for the completion. */ void resume(); + void yield(); + /** Returns true if the process is suspended. */ int isSuspended(); @@ -349,6 +351,8 @@ template inline void sleep_for(std::chrono::durationsuspended; }); } +void Actor::yield() +{ + simgrid::simix::kernelImmediate([] { /* do nothing*/ }); +} + void Actor::setKillTime(double time) { simcall_process_set_kill_time(pimpl_,time); }