foreach (example actions-comm actions-storage
- actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend actor-priority actor-yield
+ actor-create actor-daemon actor-execute actor-join actor-kill actor-lifetime actor-migration actor-suspend actor-priority actor-yield
app-masterworker app-pingpong app-token-ring
async-wait async-waitany async-waitall
energy-link energy-pstate energy-ptask
${CMAKE_CURRENT_SOURCE_DIR}/README.doc PARENT_SCOPE)
foreach(example actions-comm actions-storage
- actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend actor-priority actor-yield
+ actor-create actor-daemon actor-execute actor-join actor-kill actor-lifetime actor-migration actor-suspend actor-priority actor-yield
app-bittorrent app-masterworker app-pingpong app-token-ring
async-wait async-waitall async-waitany
dht-chord
--- /dev/null
+/* Copyright (c) 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. */
+
+#include "simgrid/s4u.hpp"
+
+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);
+ XBT_INFO("I'm done. See you!");
+}
+
+static void master()
+{
+ simgrid::s4u::ActorPtr actor;
+
+ XBT_INFO("Start sleeper");
+ actor = simgrid::s4u::Actor::createActor("sleeper from master", simgrid::s4u::Host::current(), sleeper);
+ XBT_INFO("Join the sleeper (timeout 2)");
+ actor->join(2);
+
+ XBT_INFO("Start sleeper");
+ actor = simgrid::s4u::Actor::createActor("sleeper from master", simgrid::s4u::Host::current(), sleeper);
+ XBT_INFO("Join the sleeper (timeout 4)");
+ actor->join(4);
+
+ XBT_INFO("Start sleeper");
+ actor = simgrid::s4u::Actor::createActor("sleeper from master", simgrid::s4u::Host::current(), sleeper);
+ XBT_INFO("Join the sleeper (timeout 2)");
+ actor->join(2);
+
+ XBT_INFO("Start sleeper");
+ actor = simgrid::s4u::Actor::createActor("sleeper from master", simgrid::s4u::Host::current(), sleeper);
+ XBT_INFO("Waiting 4");
+ simgrid::s4u::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);
+
+ XBT_INFO("Goodbye now!");
+}
+
+int main(int argc, char* 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]);
+
+ simgrid::s4u::Actor::createActor("master", simgrid::s4u::Host::by_name("Tremblay"), master);
+
+ e.run();
+
+ XBT_INFO("Simulation time %g", simgrid::s4u::Engine::getClock());
+
+ return 0;
+}
--- /dev/null
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-join$EXEEXT ${platfdir}/small_platform.xml
+> [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Start sleeper
+> [Tremblay:sleeper from master:(2) 0.000000] [s4u_test/INFO] Sleeper started
+> [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Join the sleeper (timeout 2)
+> [Tremblay:master:(1) 2.000000] [s4u_test/INFO] Start sleeper
+> [Tremblay:sleeper from master:(3) 2.000000] [s4u_test/INFO] Sleeper started
+> [Tremblay:master:(1) 2.000000] [s4u_test/INFO] Join the sleeper (timeout 4)
+> [Tremblay:sleeper from master:(2) 3.000000] [s4u_test/INFO] I'm done. See you!
+> [Tremblay:sleeper from master:(3) 5.000000] [s4u_test/INFO] I'm done. See you!
+> [Tremblay:master:(1) 5.000000] [s4u_test/INFO] Start sleeper
+> [Tremblay:sleeper from master:(4) 5.000000] [s4u_test/INFO] Sleeper started
+> [Tremblay:master:(1) 5.000000] [s4u_test/INFO] Join the sleeper (timeout 2)
+> [Tremblay:master:(1) 7.000000] [s4u_test/INFO] Start sleeper
+> [Tremblay:sleeper from master:(5) 7.000000] [s4u_test/INFO] Sleeper started
+> [Tremblay:master:(1) 7.000000] [s4u_test/INFO] Waiting 4
+> [Tremblay:sleeper from master:(4) 8.000000] [s4u_test/INFO] I'm done. See you!
+> [Tremblay:sleeper from master:(5) 10.000000] [s4u_test/INFO] I'm done. See you!
+> [Tremblay:master:(1) 11.000000] [s4u_test/INFO] Join the sleeper after its end (timeout 1)
+> [Tremblay:master:(1) 11.000000] [s4u_test/INFO] Goodbye now!
+> [Tremblay:master:(1) 12.000000] [s4u_test/INFO] Goodbye now!
+> [12.000000] [s4u_test/INFO] Simulation time 12
* This blocks the calling actor until the actor on which we call join() is terminated
*/
void join();
+ void join(double timeout);
// Static methods on all actors:
simcall_process_join(this->pimpl_, -1);
}
+void Actor::join(double timeout)
+{
+ simcall_process_join(this->pimpl_, timeout);
+}
+
void Actor::setAutoRestart(bool autorestart) {
simgrid::simix::kernelImmediate([this, autorestart]() { pimpl_->auto_restart = autorestart; });
}