X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/aa1f1dad959e78c1c5668a5c59023412568b913a..9afa0d0db01da2ae64e48fb594cc87c186dde192:/examples/cpp/task-switch-host/s4u-task-switch-host.cpp diff --git a/examples/cpp/task-switch-host/s4u-task-switch-host.cpp b/examples/cpp/task-switch-host/s4u-task-switch-host.cpp index b007523f73..c236bdbdb9 100644 --- a/examples/cpp/task-switch-host/s4u-task-switch-host.cpp +++ b/examples/cpp/task-switch-host/s4u-task-switch-host.cpp @@ -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); }