From cb88ded408a140d6b0ff463aec20b6275437fb7b Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 27 Nov 2017 22:10:26 +0100 Subject: [PATCH 1/1] please sonar in the new example --- .gitignore | 3 ++- examples/s4u/actor-yield/s4u-actor-yield.cpp | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index e0eb0b8fa8..f9fd051a4d 100644 --- a/.gitignore +++ b/.gitignore @@ -152,7 +152,6 @@ examples/msg/process-join/process-join examples/msg/process-migration/process-migration examples/msg/process-startkilltime/process-startkilltime examples/msg/process-suspend/process-suspend -examples/msg/process-yield/process-yield examples/msg/app-masterworker/app-masterworker examples/msg/mc/bugged1 examples/msg/mc/bugged1_liveness @@ -198,6 +197,7 @@ examples/s4u/actor-lifetime/s4u-actor-lifetime examples/s4u/actor-migration/s4u-actor-migration examples/s4u/actor-priority/s4u-actor-priority examples/s4u/actor-suspend/s4u-actor-suspend +examples/s4u/actor-yield/s4u-actor-yield examples/s4u/app-bittorrent/s4u-bittorrent examples/s4u/app-masterworker/s4u-app-masterworker examples/s4u/app-pingpong/s4u-app-pingpong @@ -273,6 +273,7 @@ teshsuite/msg/host_on_off_wait/host_on_off_wait teshsuite/msg/listen_async/listen_async teshsuite/msg/pid/pid teshsuite/msg/process/process +teshsuite/msg/process-yield/process-yield teshsuite/msg/storage_client_server/storage_client_server teshsuite/msg/task_destroy_cancel/task_destroy_cancel teshsuite/msg/task_listen_from/task_listen_from diff --git a/examples/s4u/actor-yield/s4u-actor-yield.cpp b/examples/s4u/actor-yield/s4u-actor-yield.cpp index 903ade338b..168044a8d1 100644 --- a/examples/s4u/actor-yield/s4u-actor-yield.cpp +++ b/examples/s4u/actor-yield/s4u-actor-yield.cpp @@ -18,15 +18,14 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_yield, "Messages specific for this s4u ex class yielder { long number_of_yields; public: - explicit yielder() = default; explicit yielder(std::vector args) -{ +{ number_of_yields = std::stod(args[1]); } void operator()() { - for (int i = 0; i < number_of_yields; i++) - simgrid::s4u::this_actor::yield(); + for (int i = 0; i < number_of_yields; i++) + simgrid::s4u::this_actor::yield(); XBT_INFO("I yielded %ld times. Goodbye now!", number_of_yields); } }; @@ -34,14 +33,13 @@ void operator()() int main(int argc, char* argv[]) { simgrid::s4u::Engine e(&argc, argv); - + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" "\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]); - + e.loadPlatform(argv[1]); /* - Load the platform description */ e.registerFunction("yielder"); - std::vector args; e.loadDeployment(argv[2]); -- 2.20.1