Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Plug memory leaks.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 28 Jun 2023 20:57:00 +0000 (22:57 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 28 Jun 2023 20:57:24 +0000 (22:57 +0200)
Capture by reference in order to break what I understand to be a circular dependency.

examples/cpp/task-storm/s4u-task-storm.cpp
examples/cpp/task-switch-host/s4u-task-switch-host.cpp

index 2c4edb1..5c7ae70 100644 (file)
@@ -95,12 +95,8 @@ int main(int argc, char* argv[])
   });
 
   // The token sent by SA is forwarded by both communication tasks
-  SA_to_B1->on_this_start_cb([SA](sg4::Task* t) {
-    t->set_token(t->get_next_token_from(SA));
-  });
-  SA_to_B2->on_this_start_cb([SA](sg4::Task* t) {
-    t->set_token(t->get_next_token_from(SA));
-  });
+  SA_to_B1->on_this_start_cb([&SA](sg4::Task* t) { t->set_token(t->get_next_token_from(SA)); });
+  SA_to_B2->on_this_start_cb([&SA](sg4::Task* t) { t->set_token(t->get_next_token_from(SA)); });
 
   /* B1 and B2 read the value of the token received by their predecessors
      and use it to adapt their amount of work to do.
index eee90e6..4a93265 100644 (file)
@@ -53,7 +53,7 @@ int main(int argc, char* argv[])
   // Add a function to be called before each firing of comm0
   // This function modifies the graph of tasks by adding or removing
   // successors to comm0
-  comm0->on_this_start_cb([comm0, exec1, exec2, jupiter, fafard](const sg4::Task*) {
+  comm0->on_this_start_cb([&comm0, exec1, exec2, jupiter, fafard](const sg4::Task*) {
     static int count = 0;
     if (count % 2 == 0) {
       comm0->set_destination(jupiter);