Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update python/clusters-multicpu to the new API.
[simgrid.git] / examples / cpp / task-switch-host / s4u-task-switch-host.cpp
index b007523f73a371f6aec6d961008ee78805a330a7..c236bdbdb9a4eb1bb089e024d6cf2dc42cb64310 100644 (file)
@@ -54,12 +54,19 @@ int main(int argc, char* argv[])
   // successors to comm0
   comm0->on_this_start_cb([&comm0, exec1, exec2, jupiter, fafard](const sg4::Task*) {
     static int count = 0;
-    if (count % 2 == 0) {
+    if (count % 2 == 0)
       comm0->set_destination(jupiter);
+    else
+      comm0->set_destination(fafard);
+    count++;
+  });
+
+  comm0->on_this_completion_cb([&comm0, exec1, exec2](const sg4::Task*) {
+    static int count = 0;
+    if (count % 2 == 0) {
       comm0->add_successor(exec1);
       comm0->remove_successor(exec2);
     } else {
-      comm0->set_destination(fafard);
       comm0->add_successor(exec2);
       comm0->remove_successor(exec1);
     }