Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
suggested solution tu use simix through a function
authorTakishipp <toufik.boubehziz@gmail.com>
Tue, 24 Oct 2017 14:32:11 +0000 (16:32 +0200)
committerTakishipp <toufik.boubehziz@gmail.com>
Tue, 24 Oct 2017 14:32:11 +0000 (16:32 +0200)
examples/s4u/actor-yield/s4u-actor-yield.cpp
include/simgrid/s4u/Actor.hpp
src/s4u/s4u_actor.cpp

index b5a5d92..6e79dc6 100644 (file)
@@ -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);
 }
 };
index eef1611..b4e58c9 100644 (file)
@@ -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 <class Rep, class Period> inline void sleep_for(std::chrono::duration<R
   /** @brief Resume the actor. */
   XBT_PUBLIC(void) resume();
 
+  XBT_PUBLIC(void) yield();
+
   XBT_PUBLIC(bool) isSuspended();
 
   /** @brief kill the actor. */
index f3f5ab0..db27edc 100644 (file)
@@ -120,6 +120,11 @@ int Actor::isSuspended()
   return simgrid::simix::kernelImmediate([this] { return pimpl_->suspended; });
 }
 
+void Actor::yield()
+{
+  simgrid::simix::kernelImmediate([] { /* do nothing*/ });
+}
+
 void Actor::setKillTime(double time) {
   simcall_process_set_kill_time(pimpl_,time);
 }