Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change condition for infinite loops (make sonar believe that function can return).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 3 May 2019 09:48:16 +0000 (11:48 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 3 May 2019 12:27:39 +0000 (14:27 +0200)
examples/s4u/actor-daemon/s4u-actor-daemon.cpp
teshsuite/s4u/actor-autorestart/actor-autorestart.cpp
teshsuite/s4u/actor/actor.cpp

index 54037a6..4372bd4 100644 (file)
@@ -21,7 +21,7 @@ static void my_daemon()
 {
   simgrid::s4u::Actor::self()->daemonize();
 
-  while (1) {
+  while (simgrid::s4u::this_actor::get_host()->is_on()) {
     XBT_INFO("Hello from the infinite loop");
     simgrid::s4u::this_actor::sleep_for(3.0);
   }
index cc86142..89189a9 100644 (file)
@@ -17,7 +17,7 @@ static void dummy()
 static void dummy_daemon()
 {
   simgrid::s4u::Actor::self()->daemonize();
-  while (1) {
+  while (simgrid::s4u::this_actor::get_host()->is_on()) {
     XBT_INFO("Hello from the infinite loop");
     simgrid::s4u::this_actor::sleep_for(80.0);
   }
index 6c70080..01558b2 100644 (file)
@@ -12,7 +12,7 @@ static void worker()
   simgrid::s4u::this_actor::sleep_for(.5);
   XBT_INFO("Worker started (PID:%ld, PPID:%ld)", simgrid::s4u::this_actor::get_pid(),
            simgrid::s4u::this_actor::get_ppid());
-  while (1) {
+  while (simgrid::s4u::this_actor::get_host()->is_on()) {
     simgrid::s4u::this_actor::yield();
     XBT_INFO("Plop i am not suspended");
     simgrid::s4u::this_actor::sleep_for(1);