Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fewer explicit news are fewer possible leaks
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 12 Sep 2017 22:16:56 +0000 (00:16 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 12 Sep 2017 22:16:56 +0000 (00:16 +0200)
15 files changed:
examples/s4u/actions-comm/s4u-actions-comm.cpp
examples/s4u/actions-storage/s4u-actions-storage.cpp
examples/s4u/actor-create/s4u-actor-create.cpp
examples/s4u/actor-daemon/s4u-actor-daemon.cpp
examples/s4u/actor-kill/s4u-actor-kill.cpp
examples/s4u/actor-migration/s4u-actor-migration.cpp
examples/s4u/actor-suspend/s4u-actor-suspend.cpp
examples/s4u/app-bittorrent/s4u-bittorrent.cpp
examples/s4u/app-masterworker/s4u-app-masterworker.cpp
examples/s4u/app-pingpong/s4u-app-pingpong.cpp
examples/s4u/app-token-ring/s4u-app-token-ring.cpp
examples/s4u/dht-chord/s4u-dht-chord.cpp
examples/s4u/io/s4u-io.cpp
examples/s4u/mutex/s4u-mutex.cpp
examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp

index 2779185..f620071 100644 (file)
@@ -85,7 +85,7 @@ public:
 
 int main(int argc, char *argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
 
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file [action_files]\n"
                        "\t# if all actions are in the same file\n"
@@ -94,11 +94,11 @@ int main(int argc, char *argv[])
                        "\tExample: %s msg_platform.xml msg_deployment.xml ",
              argv[0], argv[0], argv[0]);
 
-  e->loadPlatform(argv[1]);
-  e->registerDefault(&simgrid::xbt::replay_runner);
-  e->registerFunction<Replayer>("p0");
-  e->registerFunction<Replayer>("p1");
-  e->loadDeployment(argv[2]);
+  e.loadPlatform(argv[1]);
+  e.registerDefault(&simgrid::xbt::replay_runner);
+  e.registerFunction<Replayer>("p0");
+  e.registerFunction<Replayer>("p1");
+  e.loadDeployment(argv[2]);
 
   /*   Action registration */
   xbt_replay_action_register("compute", Replayer::compute);
@@ -109,15 +109,14 @@ int main(int argc, char *argv[])
     simgrid::xbt::action_fs = new std::ifstream(argv[3], std::ifstream::in);
   }
 
-  e->run();
+  e.run();
 
   if (argv[3]) {
     delete simgrid::xbt::action_fs;
     simgrid::xbt::action_fs = nullptr;
   }
 
-  XBT_INFO("Simulation time %g", e->getClock());
+  XBT_INFO("Simulation time %g", e.getClock());
 
-  delete e;
   return 0;
 }
index 85ffb9d..79a8aba 100644 (file)
@@ -102,7 +102,7 @@ public:
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
 
   xbt_assert(argc > 3, "Usage: %s platform_file deployment_file [action_files]\n"
                        "\texample: %s platform.xml deployment.xml actions # if all actions are in the same file\n"
@@ -110,10 +110,10 @@ int main(int argc, char* argv[])
                        "\texample: %s platform.xml deployment.xml",
              argv[0], argv[0], argv[0]);
 
-  e->loadPlatform(argv[1]);
-  e->registerDefault(&simgrid::xbt::replay_runner);
-  e->registerFunction<Replayer>("p0");
-  e->loadDeployment(argv[2]);
+  e.loadPlatform(argv[1]);
+  e.registerDefault(&simgrid::xbt::replay_runner);
+  e.registerFunction<Replayer>("p0");
+  e.loadDeployment(argv[2]);
 
   /*   Action registration */
   xbt_replay_action_register("open", Replayer::open);
@@ -124,15 +124,14 @@ int main(int argc, char* argv[])
     simgrid::xbt::action_fs = new std::ifstream(argv[3], std::ifstream::in);
   }
 
-  e->run();
+  e.run();
 
   if (argv[3]) {
     delete simgrid::xbt::action_fs;
     simgrid::xbt::action_fs = nullptr;
   }
 
-  XBT_INFO("Simulation time %g", e->getClock());
+  XBT_INFO("Simulation time %g", e.getClock());
 
-  delete e;
   return 0;
 }
index ca6cd9b..33ed245 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -87,10 +87,10 @@ public:
 int main(int argc, char** argv)
 {
   /* When your program starts, you have to first start a new simulation engine, as follows */
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
 
   /* Then you should load a platform file, describing your simulated platform */
-  e->loadPlatform("../../platforms/small_platform.xml");
+  e.loadPlatform("../../platforms/small_platform.xml");
 
   /* And now you have to ask SimGrid to actually start your actors.
    *
@@ -100,21 +100,19 @@ int main(int argc, char** argv)
   simgrid::s4u::Actor::createActor("sender1", simgrid::s4u::Host::by_name("Tremblay"), Sender());
 
   /* The second way is to first register your function, and then retrieve it */
-  e->registerFunction<Sender>("sender"); // The sender is passed as a template parameter here
+  e.registerFunction<Sender>("sender");  // The sender is passed as a template parameter here
   std::vector<std::string> args;         // Here we declare the parameter that the actor will get
   args.push_back("GloubiBoulga");        // Add a parameter to the set (we could have done it in the first approach too)
 
   simgrid::s4u::Actor::createActor("sender2", simgrid::s4u::Host::by_name("Jupiter"), "sender", args);
 
   /* The third way to start your actors is to use a deployment file. */
-  e->registerFunction<Receiver>("receiver");   // You first have to register the actor as with the second approach
-  e->loadDeployment("s4u-actor-create_d.xml"); // And then, you load the deployment file
+  e.registerFunction<Receiver>("receiver");   // You first have to register the actor as with the second approach
+  e.loadDeployment("s4u-actor-create_d.xml"); // And then, you load the deployment file
 
   /* Once every actors are started in the engine, the simulation can start */
-  e->run();
+  e.run();
 
   /* Once the simulation is done, the program is ended */
-  delete e;
-
   return 0;
 }
index b415f28..4c8d19c 100644 (file)
@@ -31,14 +31,12 @@ static void my_daemon()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
 
-  e->loadPlatform(argv[1]);
+  e.loadPlatform(argv[1]);
   simgrid::s4u::Actor::createActor("worker", simgrid::s4u::Host::by_name("Boivin"), worker);
   simgrid::s4u::Actor::createActor("daemon", simgrid::s4u::Host::by_name("Tremblay"), my_daemon);
 
-  e->run();
-
-  delete e;
+  e.run();
   return 0;
 }
index e6a77aa..81ce0a2 100644 (file)
@@ -38,17 +38,16 @@ static void killer()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
 
-  e->loadPlatform(argv[1]); /* - Load the platform description */
+  e.loadPlatform(argv[1]); /* - Load the platform description */
   /* - Create and deploy killer process, that will create the victim process  */
   simgrid::s4u::Actor::createActor("killer", simgrid::s4u::Host::by_name("Tremblay"), killer);
 
-  e->run(); /* - Run the simulation */
+  e.run(); /* - Run the simulation */
 
-  XBT_INFO("Simulation time %g", e->getClock());
+  XBT_INFO("Simulation time %g", e.getClock());
 
-  delete e;
   return 0;
 }
index 102843c..5db7924 100644 (file)
@@ -58,9 +58,9 @@ static void policeman()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
-  e->loadPlatform(argv[1]); /* - Load the platform description */
+  e.loadPlatform(argv[1]); /* - Load the platform description */
 
   /* - Create and deploy the emigrant and policeman processes */
   simgrid::s4u::Actor::createActor("emigrant", simgrid::s4u::Host::by_name("Jacquelin"), emigrant);
@@ -68,10 +68,9 @@ int main(int argc, char* argv[])
 
   checkpoint     = simgrid::s4u::Mutex::createMutex(); /* - Initiate the mutex and conditions */
   identification = simgrid::s4u::ConditionVariable::createConditionVariable();
-  e->run();
+  e.run();
 
-  XBT_INFO("Simulation time %g", e->getClock());
+  XBT_INFO("Simulation time %g", e.getClock());
 
-  delete e;
   return 0;
 }
index 9d98a4a..b663e8e 100644 (file)
@@ -66,16 +66,15 @@ static void dream_master()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
 
-  e->loadPlatform(argv[1]); /* - Load the platform description */
+  e.loadPlatform(argv[1]); /* - Load the platform description */
   std::vector<simgrid::s4u::Host*> list;
-  e->getHostList(&list);
+  e.getHostList(&list);
   simgrid::s4u::Actor::createActor("dream_master", list.front(), dream_master);
 
-  e->run(); /* - Run the simulation */
+  e.run(); /* - Run the simulation */
 
-  delete e;
   return 0;
 }
index d205165..38709b0 100644 (file)
@@ -12,12 +12,12 @@ simgrid::xbt::Extension<simgrid::s4u::Host, HostBittorrent> HostBittorrent::EXTE
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
 
   /* Check the arguments */
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file", argv[0]);
 
-  e->loadPlatform(argv[1]);
+  e.loadPlatform(argv[1]);
 
   HostBittorrent::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostBittorrent>();
 
@@ -26,12 +26,11 @@ int main(int argc, char* argv[])
   for (auto const& host : list)
     host->extension_set(new HostBittorrent(host));
 
-  e->registerFunction<Tracker>("tracker");
-  e->registerFunction<Peer>("peer");
-  e->loadDeployment(argv[2]);
+  e.registerFunction<Tracker>("tracker");
+  e.registerFunction<Peer>("peer");
+  e.loadDeployment(argv[2]);
 
-  e->run();
+  e.run();
 
-  delete e;
   return 0;
 }
index c0ce006..d360480 100644 (file)
@@ -85,20 +85,19 @@ public:
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
                        "\tExample: %s msg_platform.xml msg_deployment.xml\n",
              argv[0], argv[0]);
 
-  e->loadPlatform(argv[1]);              /** - Load the platform description */
-  e->registerFunction<Master>("master");
-  e->registerFunction<Worker>("worker"); /** - Register the function to be executed by the processes */
-  e->loadDeployment(argv[2]);            /** - Deploy the application */
+  e.loadPlatform(argv[1]); /** - Load the platform description */
+  e.registerFunction<Master>("master");
+  e.registerFunction<Worker>("worker"); /** - Register the function to be executed by the processes */
+  e.loadDeployment(argv[2]);            /** - Deploy the application */
 
-  e->run(); /** - Run the simulation */
+  e.run(); /** - Run the simulation */
 
-  XBT_INFO("Simulation time %g", e->getClock());
+  XBT_INFO("Simulation time %g", e.getClock());
 
-  delete e;
   return 0;
 }
index d47ff48..a644f69 100644 (file)
@@ -54,9 +54,9 @@ static void ponger(std::vector<std::string> args)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
 
-  e->loadPlatform(argv[1]);
+  e.loadPlatform(argv[1]);
   std::vector<std::string> args;
   args.push_back("Jupiter");
   simgrid::s4u::Actor::createActor("pinger", simgrid::s4u::Host::by_name("Tremblay"), pinger, args);
@@ -66,10 +66,9 @@ int main(int argc, char* argv[])
 
   simgrid::s4u::Actor::createActor("ponger", simgrid::s4u::Host::by_name("Jupiter"), ponger, args);
 
-  e->run();
+  e.run();
 
-  XBT_INFO("Total simulation time: %.3f", e->getClock());
-  delete e;
+  XBT_INFO("Total simulation time: %.3f", e.getClock());
 
   return 0;
 }
index a5c3d7f..ce84f9c 100644 (file)
@@ -55,22 +55,21 @@ public:
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]);
-  e->loadPlatform(argv[1]);
+  e.loadPlatform(argv[1]);
 
-  XBT_INFO("Number of hosts '%zu'", e->getHostCount());
+  XBT_INFO("Number of hosts '%zu'", e.getHostCount());
   int id = 0;
   std::vector<simgrid::s4u::Host*> list;
-  e->getHostList(&list);
+  e.getHostList(&list);
   for (auto const& host : list) {
     /* - Give a unique rank to each host and create a @ref relay_runner process on each */
     simgrid::s4u::Actor::createActor((std::to_string(id)).c_str(), host, RelayRunner());
     id++;
   }
-  e->run();
-  XBT_INFO("Simulation time %g", e->getClock());
+  e.run();
+  XBT_INFO("Simulation time %g", e.getClock());
 
-  delete e;
   return 0;
 }
index 96bae87..5c819f1 100644 (file)
@@ -41,7 +41,7 @@ static void chord_exit()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n"
                        "\tExample: %s ../msg_platform.xml chord.xml\n",
              argv[0], argv[0]);
@@ -63,19 +63,18 @@ int main(int argc, char* argv[])
     options++;
   }
 
-  e->loadPlatform(options[0]);
+  e.loadPlatform(options[0]);
 
   chord_init();
 
-  e->registerFunction<Node>("node");
-  e->loadDeployment(options[1]);
+  e.registerFunction<Node>("node");
+  e.loadDeployment(options[1]);
 
-  e->run();
+  e.run();
 
-  XBT_INFO("Simulated time: %g", e->getClock());
+  XBT_INFO("Simulated time: %g", e.getClock());
 
   chord_exit();
 
-  delete e;
   return 0;
 }
index 789bf1c..fb4bc28 100644 (file)
@@ -83,10 +83,10 @@ public:
 
 int main(int argc, char **argv)
 {
-  simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv);
-  e->loadPlatform("../../platforms/storage/storage.xml");
+  simgrid::s4u::Engine e(&argc, argv);
+  e.loadPlatform("../../platforms/storage/storage.xml");
   simgrid::s4u::Actor::createActor("host", simgrid::s4u::Host::by_name("denise"), MyHost());
-  e->run();
-  delete e;
+  e.run();
+
   return 0;
 }
index 2f2afd9..b1e3523 100644 (file)
@@ -60,11 +60,10 @@ static void master()
 
 int main(int argc, char **argv)
 {
-  simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv);
-  e->loadPlatform("../../platforms/two_hosts.xml");
+  simgrid::s4u::Engine e(&argc, argv);
+  e.loadPlatform("../../platforms/two_hosts.xml");
   simgrid::s4u::Actor::createActor("main", simgrid::s4u::Host::by_name("Tremblay"), master);
-  e->run();
+  e.run();
 
-  delete e;
   return 0;
 }
index 3f6efc4..5ddec37 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2007-2010, 2013-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -69,17 +68,16 @@ static void execute_load_test()
 int main(int argc, char* argv[])
 {
   sg_host_load_plugin_init();
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
-  e->loadPlatform(argv[1]);
+  e.loadPlatform(argv[1]);
 
   simgrid::s4u::Actor::createActor("load_test", simgrid::s4u::Host::by_name("MyHost1"), execute_load_test);
 
-  e->run();
+  e.run();
 
   XBT_INFO("Total simulation time: %.2f", simgrid::s4u::Engine::getClock());
 
-  delete e;
   return 0;
 }