#include <simgrid/s4u.hpp>
#include <string>
+namespace sg4 = simgrid::s4u;
// This declares a logging channel so that XBT_INFO can be used later
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_create, "The logging channel used in this example");
*/
static void receiver(const std::string& mailbox_name)
{
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
+ sg4::Mailbox* mailbox = sg4::Mailbox::by_name(mailbox_name);
XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->get_cname());
static void forwarder(int argc, char** argv)
{
xbt_assert(argc >= 3, "Actor forwarder requires 2 parameters, but got only %d", argc - 1);
- simgrid::s4u::Mailbox* in = simgrid::s4u::Mailbox::by_name(argv[1]);
- simgrid::s4u::Mailbox* out = simgrid::s4u::Mailbox::by_name(argv[2]);
+ sg4::Mailbox* in = sg4::Mailbox::by_name(argv[1]);
+ sg4::Mailbox* out = sg4::Mailbox::by_name(argv[2]);
auto* msg = in->get<std::string>();
XBT_INFO("Forward '%s'.", msg->c_str());
out->put(msg, msg->size());
void operator()() const /* This is the main code of the actor */
{
XBT_INFO("Hello s4u, I have something to send");
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mbox);
+ sg4::Mailbox* mailbox = sg4::Mailbox::by_name(mbox);
mailbox->put(new std::string(msg), msg.size());
XBT_INFO("I'm done. See you.");
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(&argc, argv);
+ sg4::Engine e(&argc, argv);
/* Then you should load a platform file, describing your simulated platform */
e.load_platform("../../platforms/small_platform.xml");
* as we do here for the receiver actors. This function can take any kind of parameters, as
* long as the last parameters of Actor::create() match what your function expects.
*/
- simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("Fafard"), &receiver, "mb42");
+ sg4::Actor::create("receiver", sg4::Host::by_name("Fafard"), &receiver, "mb42");
/* If your actor is getting more complex, you probably want to implement it as a class instead,
* as we do here for the sender actors. The main behavior goes into operator()() of the class.
*
* You can then directly start your actor, as follows: */
- simgrid::s4u::Actor::create("sender1", simgrid::s4u::Host::by_name("Tremblay"), Sender());
+ sg4::Actor::create("sender1", sg4::Host::by_name("Tremblay"), Sender());
/* If you want to pass parameters to your class, that's very easy: just use your constructors */
- simgrid::s4u::Actor::create("sender2", simgrid::s4u::Host::by_name("Jupiter"), Sender("GloubiBoulga"));
+ sg4::Actor::create("sender2", sg4::Host::by_name("Jupiter"), Sender("GloubiBoulga"));
/* But starting actors directly is considered as a bad experimental habit, since it ties the code
* you want to test with the experimental scenario. Starting your actors from an external deployment
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/s4u.hpp"
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_daemon, "Messages specific for this s4u example");
static void worker()
{
XBT_INFO("Let's do some work (for 10 sec on Boivin).");
- simgrid::s4u::this_actor::execute(980.95e6);
+ sg4::this_actor::execute(980.95e6);
XBT_INFO("I'm done now. I leave even if it makes the daemon die.");
}
/* The daemon, displaying a message every 3 seconds until all other actors stop */
static void my_daemon()
{
- simgrid::s4u::Actor::self()->daemonize();
+ sg4::Actor::self()->daemonize();
- while (simgrid::s4u::this_actor::get_host()->is_on()) {
+ while (sg4::this_actor::get_host()->is_on()) {
XBT_INFO("Hello from the infinite loop");
- simgrid::s4u::this_actor::sleep_for(3.0);
+ sg4::this_actor::sleep_for(3.0);
}
XBT_INFO("I will never reach that point: daemons are killed when regular actors are done");
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
e.load_platform(argv[1]);
- simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Boivin"), worker);
- simgrid::s4u::Actor::create("daemon", simgrid::s4u::Host::by_name("Tremblay"), my_daemon);
+ sg4::Actor::create("worker", sg4::Host::by_name("Boivin"), worker);
+ sg4::Actor::create("daemon", sg4::Host::by_name("Tremblay"), my_daemon);
e.run();
return 0;
*/
#include <simgrid/s4u.hpp>
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_exiting, "Messages specific for this s4u example");
static void actor_a()
{
// Register a lambda function to be executed once it stops
- simgrid::s4u::this_actor::on_exit([](bool /*failed*/) { XBT_INFO("I stop now"); });
+ sg4::this_actor::on_exit([](bool /*failed*/) { XBT_INFO("I stop now"); });
- simgrid::s4u::this_actor::sleep_for(1);
+ sg4::this_actor::sleep_for(1);
}
static void actor_b()
{
- simgrid::s4u::this_actor::sleep_for(2);
+ sg4::this_actor::sleep_for(2);
}
static void actor_c()
{
// Register a lambda function to be executed once it stops
- simgrid::s4u::this_actor::on_exit([](bool failed) {
+ sg4::this_actor::on_exit([](bool failed) {
if (failed) {
XBT_INFO("I was killed!");
if (xbt_log_no_loc)
XBT_INFO("Exiting gracefully.");
});
- simgrid::s4u::this_actor::sleep_for(3);
+ sg4::this_actor::sleep_for(3);
XBT_INFO("And now, induce a deadlock by waiting for a message that will never come\n\n");
- simgrid::s4u::Mailbox::by_name("nobody")->get<void>();
+ sg4::Mailbox::by_name("nobody")->get<void>();
xbt_die("Receiving is not supposed to succeed when nobody is sending");
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);
e.load_platform(argv[1]); /* - Load the platform description */
/* Register a callback in the Actor::on_termination signal. It will be called for every terminated actors */
- simgrid::s4u::Actor::on_termination.connect(
- [](simgrid::s4u::Actor const& actor) { XBT_INFO("Actor %s terminates now", actor.get_cname()); });
+ sg4::Actor::on_termination.connect(
+ [](sg4::Actor const& actor) { XBT_INFO("Actor %s terminates now", actor.get_cname()); });
/* Register a callback in the Actor::on_destruction signal. It will be called for every destructed actors */
- simgrid::s4u::Actor::on_destruction.connect(
- [](simgrid::s4u::Actor const& actor) { XBT_INFO("Actor %s gets destroyed now", actor.get_cname()); });
+ sg4::Actor::on_destruction.connect(
+ [](sg4::Actor const& actor) { XBT_INFO("Actor %s gets destroyed now", actor.get_cname()); });
/* Create some actors */
- simgrid::s4u::Actor::create("A", simgrid::s4u::Host::by_name("Tremblay"), actor_a);
- simgrid::s4u::Actor::create("B", simgrid::s4u::Host::by_name("Fafard"), actor_b);
- simgrid::s4u::Actor::create("C", simgrid::s4u::Host::by_name("Ginette"), actor_c);
+ sg4::Actor::create("A", sg4::Host::by_name("Tremblay"), actor_a);
+ sg4::Actor::create("B", sg4::Host::by_name("Fafard"), actor_b);
+ sg4::Actor::create("C", sg4::Host::by_name("Ginette"), actor_c);
e.run(); /* - Run the simulation */
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/s4u.hpp"
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
static void sleeper()
{
XBT_INFO("Sleeper started");
- simgrid::s4u::this_actor::sleep_for(3);
+ sg4::this_actor::sleep_for(3);
XBT_INFO("I'm done. See you!");
}
static void master()
{
- simgrid::s4u::ActorPtr actor;
+ sg4::ActorPtr actor;
XBT_INFO("Start sleeper");
- actor = simgrid::s4u::Actor::create("sleeper from master", simgrid::s4u::Host::current(), sleeper);
+ actor = sg4::Actor::create("sleeper from master", sg4::Host::current(), sleeper);
XBT_INFO("Join the sleeper (timeout 2)");
actor->join(2);
XBT_INFO("Start sleeper");
- actor = simgrid::s4u::Actor::create("sleeper from master", simgrid::s4u::Host::current(), sleeper);
+ actor = sg4::Actor::create("sleeper from master", sg4::Host::current(), sleeper);
XBT_INFO("Join the sleeper (timeout 4)");
actor->join(4);
XBT_INFO("Start sleeper");
- actor = simgrid::s4u::Actor::create("sleeper from master", simgrid::s4u::Host::current(), sleeper);
+ actor = sg4::Actor::create("sleeper from master", sg4::Host::current(), sleeper);
XBT_INFO("Join the sleeper (timeout 2)");
actor->join(2);
XBT_INFO("Start sleeper");
- actor = simgrid::s4u::Actor::create("sleeper from master", simgrid::s4u::Host::current(), sleeper);
+ actor = sg4::Actor::create("sleeper from master", sg4::Host::current(), sleeper);
XBT_INFO("Waiting 4");
- simgrid::s4u::this_actor::sleep_for(4);
+ sg4::this_actor::sleep_for(4);
XBT_INFO("Join the sleeper after its end (timeout 1)");
actor->join(1);
XBT_INFO("Goodbye now!");
- simgrid::s4u::this_actor::sleep_for(1);
+ sg4::this_actor::sleep_for(1);
XBT_INFO("Goodbye now!");
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);
e.load_platform(argv[1]);
- simgrid::s4u::Actor::create("master", simgrid::s4u::Host::by_name("Tremblay"), master);
+ sg4::Actor::create("master", sg4::Host::by_name("Tremblay"), master);
e.run();
- XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+ XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
return 0;
}
* under the terms of the license (GNU LGPL) which comes with this package. */
#include <simgrid/s4u.hpp>
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_kill, "Messages specific for this s4u example");
static void victimA_fun()
{
- simgrid::s4u::this_actor::on_exit([](bool /*failed*/) { XBT_INFO("I have been killed!"); });
+ sg4::this_actor::on_exit([](bool /*failed*/) { XBT_INFO("I have been killed!"); });
XBT_INFO("Hello!");
XBT_INFO("Suspending myself");
- simgrid::s4u::this_actor::suspend(); /* - Start by suspending itself */
+ sg4::this_actor::suspend(); /* - Start by suspending itself */
XBT_INFO("OK, OK. Let's work"); /* - Then is resumed and start to execute some flops */
- simgrid::s4u::this_actor::execute(1e9);
+ sg4::this_actor::execute(1e9);
XBT_INFO("Bye!"); /* - But will never reach the end of it */
}
static void killer()
{
XBT_INFO("Hello!"); /* - First start a victim actor */
- simgrid::s4u::ActorPtr victimA =
- simgrid::s4u::Actor::create("victim A", simgrid::s4u::Host::by_name("Fafard"), victimA_fun);
- simgrid::s4u::ActorPtr victimB =
- simgrid::s4u::Actor::create("victim B", simgrid::s4u::Host::by_name("Jupiter"), victimB_fun);
- simgrid::s4u::this_actor::sleep_for(10); /* - Wait for 10 seconds */
+ sg4::ActorPtr victimA = sg4::Actor::create("victim A", sg4::Host::by_name("Fafard"), victimA_fun);
+ sg4::ActorPtr victimB = sg4::Actor::create("victim B", sg4::Host::by_name("Jupiter"), victimB_fun);
+ sg4::this_actor::sleep_for(10); /* - Wait for 10 seconds */
XBT_INFO("Resume the victim A"); /* - Resume it from its suspended state */
victimA->resume();
- simgrid::s4u::this_actor::sleep_for(2);
+ sg4::this_actor::sleep_for(2);
XBT_INFO("Kill the victim A"); /* - and then kill it */
- simgrid::s4u::Actor::by_pid(victimA->get_pid())->kill(); // You can retrieve an actor from its PID (and then kill it)
+ sg4::Actor::by_pid(victimA->get_pid())->kill(); // You can retrieve an actor from its PID (and then kill it)
- simgrid::s4u::this_actor::sleep_for(1);
+ sg4::this_actor::sleep_for(1);
XBT_INFO("Kill victimB, even if it's already dead"); /* that's a no-op, there is no zombies in SimGrid */
victimB->kill(); // the actor is automatically garbage-collected after this last reference
- simgrid::s4u::this_actor::sleep_for(1);
+ sg4::this_actor::sleep_for(1);
XBT_INFO("Start a new actor, and kill it right away");
- simgrid::s4u::ActorPtr victimC =
- simgrid::s4u::Actor::create("victim C", simgrid::s4u::Host::by_name("Jupiter"), victimA_fun);
+ sg4::ActorPtr victimC = sg4::Actor::create("victim C", sg4::Host::by_name("Jupiter"), victimA_fun);
victimC->kill();
- simgrid::s4u::this_actor::sleep_for(1);
+ sg4::this_actor::sleep_for(1);
XBT_INFO("Killing everybody but myself");
- simgrid::s4u::Actor::kill_all();
+ sg4::Actor::kill_all();
XBT_INFO("OK, goodbye now. I commit a suicide.");
- simgrid::s4u::this_actor::exit();
+ sg4::this_actor::exit();
XBT_INFO("This line never gets displayed: I'm already dead since the previous line.");
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);
e.load_platform(argv[1]); /* - Load the platform description */
/* - Create and deploy killer actor, that will create the victim actors */
- simgrid::s4u::Actor::create("killer", simgrid::s4u::Host::by_name("Tremblay"), killer);
+ sg4::Actor::create("killer", sg4::Host::by_name("Tremblay"), killer);
e.run(); /* - Run the simulation */
action takes place: Actors are started and stopped at predefined time. */
#include "simgrid/s4u.hpp"
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific for this s4u example");
public:
explicit sleeper(std::vector<std::string> /*args*/)
{
- simgrid::s4u::this_actor::on_exit([](bool /*failed*/) {
+ sg4::this_actor::on_exit([](bool /*failed*/) {
/* Executed on actor termination, to display a message helping to understand the output */
XBT_INFO("Exiting now (done sleeping or got killed).");
});
void operator()() const
{
XBT_INFO("Hello! I go to sleep.");
- simgrid::s4u::this_actor::sleep_for(10);
+ sg4::this_actor::sleep_for(10);
XBT_INFO("Done sleeping.");
}
};
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
xbt_assert(argc > 2,
"Usage: %s platform_file deployment_file\n"
*/
#include <simgrid/s4u.hpp>
-#include <simgrid/s4u/Mutex.hpp>
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_migration, "Messages specific for this s4u example");
-static void worker(simgrid::s4u::Host* first, const simgrid::s4u::Host* second)
+static void worker(sg4::Host* first, const sg4::Host* second)
{
double flopAmount = first->get_speed() * 5 + second->get_speed() * 5;
XBT_INFO("Let's move to %s to execute %.2f Mflops (5sec on %s and 5sec on %s)", first->get_cname(), flopAmount / 1e6,
first->get_cname(), second->get_cname());
- simgrid::s4u::this_actor::set_host(first);
- simgrid::s4u::this_actor::execute(flopAmount);
+ sg4::this_actor::set_host(first);
+ sg4::this_actor::execute(flopAmount);
- XBT_INFO("I wake up on %s. Let's suspend a bit", simgrid::s4u::this_actor::get_host()->get_cname());
+ XBT_INFO("I wake up on %s. Let's suspend a bit", sg4::this_actor::get_host()->get_cname());
- simgrid::s4u::this_actor::suspend();
+ sg4::this_actor::suspend();
- XBT_INFO("I wake up on %s", simgrid::s4u::this_actor::get_host()->get_cname());
+ XBT_INFO("I wake up on %s", sg4::this_actor::get_host()->get_cname());
XBT_INFO("Done");
}
static void monitor()
{
- simgrid::s4u::Host* boivin = simgrid::s4u::Host::by_name("Boivin");
- simgrid::s4u::Host* jacquelin = simgrid::s4u::Host::by_name("Jacquelin");
- simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard");
+ sg4::Host* boivin = sg4::Host::by_name("Boivin");
+ sg4::Host* jacquelin = sg4::Host::by_name("Jacquelin");
+ sg4::Host* fafard = sg4::Host::by_name("Fafard");
- simgrid::s4u::ActorPtr actor = simgrid::s4u::Actor::create("worker", fafard, worker, boivin, jacquelin);
+ sg4::ActorPtr actor = sg4::Actor::create("worker", fafard, worker, boivin, jacquelin);
- simgrid::s4u::this_actor::sleep_for(5);
+ sg4::this_actor::sleep_for(5);
XBT_INFO("After 5 seconds, move the actor to %s", jacquelin->get_cname());
actor->set_host(jacquelin);
- simgrid::s4u::this_actor::sleep_until(15);
+ sg4::this_actor::sleep_until(15);
XBT_INFO("At t=15, move the actor to %s and resume it.", fafard->get_cname());
actor->set_host(fafard);
actor->resume();
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);
e.load_platform(argv[1]);
- simgrid::s4u::Actor::create("monitor", simgrid::s4u::Host::by_name("Boivin"), monitor);
+ sg4::Actor::create("monitor", sg4::Host::by_name("Boivin"), monitor);
e.run();
return 0;
/* This code tests that we can change the stack-size between the actors creation. */
-#include "simgrid/s4u.hpp"
+#include <simgrid/s4u.hpp>
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
e.load_platform(argv[1]);
// If you don't specify anything, you get the default size (8Mb) or the one passed on the command line
- simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
+ sg4::Actor::create("actor", sg4::Host::by_name("Tremblay"), actor);
// You can use set_config(string) to pass a size that will be parsed. That value will be used for any subsequent
// actors
- simgrid::s4u::Engine::set_config("contexts/stack-size:16384");
- simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
- simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
+ sg4::Engine::set_config("contexts/stack-size:16384");
+ sg4::Actor::create("actor", sg4::Host::by_name("Tremblay"), actor);
+ sg4::Actor::create("actor", sg4::Host::by_name("Tremblay"), actor);
// You can use set_config(key, value) for the same effect.
- simgrid::s4u::Engine::set_config("contexts/stack-size", 32 * 1024);
- simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
- simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
+ sg4::Engine::set_config("contexts/stack-size", 32 * 1024);
+ sg4::Actor::create("actor", sg4::Host::by_name("Tremblay"), actor);
+ sg4::Actor::create("actor", sg4::Host::by_name("Tremblay"), actor);
// Or you can use set_stacksize() before starting the actor to modify only this one
- simgrid::s4u::Actor::init("actor", simgrid::s4u::Host::by_name("Tremblay"))->set_stacksize(64 * 1024)->start(actor);
- simgrid::s4u::Actor::create("actor", simgrid::s4u::Host::by_name("Tremblay"), actor);
+ sg4::Actor::init("actor", sg4::Host::by_name("Tremblay"))->set_stacksize(64 * 1024)->start(actor);
+ sg4::Actor::create("actor", sg4::Host::by_name("Tremblay"), actor);
e.run();
XBT_INFO("Simulation time %g", e.get_clock());
* under the terms of the license (GNU LGPL) which comes with this package. */
#include <simgrid/s4u.hpp>
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_suspend, "Messages specific for this s4u example");
static void lazy_guy()
{
XBT_INFO("Nobody's watching me ? Let's go to sleep.");
- simgrid::s4u::this_actor::suspend(); /* - Start by suspending itself */
+ sg4::this_actor::suspend(); /* - Start by suspending itself */
XBT_INFO("Uuuh ? Did somebody call me ?");
XBT_INFO("Going to sleep..."); /* - Then repetitively go to sleep, but got awaken */
- simgrid::s4u::this_actor::sleep_for(10);
+ sg4::this_actor::sleep_for(10);
XBT_INFO("Mmm... waking up.");
XBT_INFO("Going to sleep one more time (for 10 sec)...");
- simgrid::s4u::this_actor::sleep_for(10);
+ sg4::this_actor::sleep_for(10);
XBT_INFO("Waking up once for all!");
XBT_INFO("Ok, let's do some work, then (for 10 sec on Boivin).");
- simgrid::s4u::this_actor::execute(980.95e6);
+ sg4::this_actor::execute(980.95e6);
XBT_INFO("Mmmh, I'm done now. Goodbye.");
}
static void dream_master()
{
XBT_INFO("Let's create a lazy guy."); /* - Create a lazy_guy actor */
- simgrid::s4u::ActorPtr lazy = simgrid::s4u::Actor::create("Lazy", simgrid::s4u::this_actor::get_host(), lazy_guy);
+ sg4::ActorPtr lazy = sg4::Actor::create("Lazy", sg4::this_actor::get_host(), lazy_guy);
XBT_INFO("Let's wait a little bit...");
- simgrid::s4u::this_actor::sleep_for(10); /* - Wait for 10 seconds */
+ sg4::this_actor::sleep_for(10); /* - Wait for 10 seconds */
XBT_INFO("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!");
if (lazy->is_suspended())
lazy->resume(); /* - Then wake up the lazy_guy */
else
XBT_ERROR("I was thinking that the lazy guy would be suspended now");
- simgrid::s4u::this_actor::sleep_for(5); /* Repeat two times: */
+ sg4::this_actor::sleep_for(5); /* Repeat two times: */
XBT_INFO("Suspend the lazy guy while he's sleeping...");
lazy->suspend(); /* - Suspend the lazy_guy while he's asleep */
XBT_INFO("Let him finish his siesta.");
- simgrid::s4u::this_actor::sleep_for(10); /* - Wait for 10 seconds */
+ sg4::this_actor::sleep_for(10); /* - Wait for 10 seconds */
XBT_INFO("Wake up, lazy guy!");
lazy->resume(); /* - Then wake up the lazy_guy again */
- simgrid::s4u::this_actor::sleep_for(5);
+ sg4::this_actor::sleep_for(5);
XBT_INFO("Suspend again the lazy guy while he's sleeping...");
lazy->suspend();
XBT_INFO("This time, don't let him finish his siesta.");
- simgrid::s4u::this_actor::sleep_for(2);
+ sg4::this_actor::sleep_for(2);
XBT_INFO("Wake up, lazy guy!");
lazy->resume();
- simgrid::s4u::this_actor::sleep_for(5);
+ sg4::this_actor::sleep_for(5);
XBT_INFO("Give a 2 seconds break to the lazy guy while he's working...");
lazy->suspend();
- simgrid::s4u::this_actor::sleep_for(2);
+ sg4::this_actor::sleep_for(2);
XBT_INFO("Back to work, lazy guy!");
lazy->resume();
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);
e.load_platform(argv[1]); /* - Load the platform description */
- std::vector<simgrid::s4u::Host*> list = e.get_all_hosts();
- simgrid::s4u::Actor::create("dream_master", list.front(), dream_master);
+ std::vector<sg4::Host*> list = e.get_all_hosts();
+ sg4::Actor::create("dream_master", list.front(), dream_master);
e.run(); /* - Run the simulation */
/* 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. */
-#include "simgrid/s4u.hpp"
+#include <simgrid/s4u.hpp>
+namespace sg4 = simgrid::s4u;
/* This example does not much: It just spans over-polite actor that yield a large amount
* of time before ending.
*
- * This serves as an example for the simgrid::s4u::this_actor::yield() function, with which an actor can request
+ * This serves as an example for the sg4::this_actor::yield() function, with which an actor can request
* to be rescheduled after the other actor that are ready at the current timestamp.
*
* It can also be used to benchmark our context-switching mechanism.
void operator()() const
{
for (int i = 0; i < number_of_yields; i++)
- simgrid::s4u::this_actor::yield();
+ sg4::this_actor::yield();
XBT_INFO("I yielded %ld times. Goodbye now!", number_of_yields);
}
};
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
"\tExample: %s platform.xml deployment.xml\n",