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"
"\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);
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;
}
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"
"\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);
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;
}
-/* 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. */
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.
*
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;
}
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;
}
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;
}
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);
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;
}
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;
}
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>();
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;
}
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;
}
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);
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;
}
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;
}
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]);
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;
}
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;
}
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;
}
-/* 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. */
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;
}