include teshsuite/s4u/vm-live-migration/vm-live-migration.tesh
include teshsuite/s4u/vm-suicide/vm-suicide.cpp
include teshsuite/s4u/vm-suicide/vm-suicide.tesh
+include teshsuite/s4u/wait-all-for/wait-all-for.cpp
+include teshsuite/s4u/wait-all-for/wait-all-for.tesh
include teshsuite/s4u/wait-any-for/wait-any-for.cpp
include teshsuite/s4u/wait-any-for/wait-any-for.tesh
include teshsuite/simdag/availability/availability.c
foreach(x actor actor-autorestart actor-suspend
activity-lifecycle
- comm-get-sender comm-pt2pt wait-any-for
+ comm-get-sender comm-pt2pt wait-all-for wait-any-for
cloud-interrupt-migration cloud-two-execs
concurrent_rw
host-on-off host-on-off-actors host-on-off-recv
## Add the tests.
## Some need to be run with all factories, some don't need tesh to run
foreach(x actor actor-autorestart actor-suspend
- activity-lifecycle comm-get-sender wait-any-for
+ activity-lifecycle comm-get-sender wait-all-for wait-any-for
cloud-interrupt-migration cloud-two-execs concurrent_rw
vm-live-migration vm-suicide)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
--- /dev/null
+/* Copyright (c) 2019-2021. 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 <cstdlib>
+#include <iostream>
+#include <simgrid/s4u.hpp>
+#include <string>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(meh, "meh");
+
+static void worker()
+{
+ auto mbox = simgrid::s4u::Mailbox::by_name("meh");
+ int input1 = 42;
+ int input2 = 51;
+
+ XBT_INFO("Sending and receiving %d and %d asynchronously", input1, input2);
+
+ auto put1 = mbox->put_async(&input1, 1000 * 1000 * 500);
+ auto put2 = mbox->put_async(&input2, 1000 * 1000 * 1000);
+
+ int* out1;
+ auto get1 = mbox->get_async<int>(&out1);
+
+ int* out2;
+ auto get2 = mbox->get_async<int>(&out2);
+
+ XBT_INFO("All comms have started");
+ std::vector<simgrid::s4u::CommPtr> comms = {put1, put2, get1, get2};
+
+ while (not comms.empty()) {
+ size_t index = simgrid::s4u::Comm::wait_all_for(&comms, 0.5);
+ if (index < comms.size())
+ XBT_INFO("wait_all_for: Timeout reached");
+ XBT_INFO("wait_all_for: %zu comms finished (#comms=%zu)", index, comms.size());
+ comms.erase(comms.begin(), comms.begin() + index);
+ }
+
+ XBT_INFO("All comms have finished");
+ XBT_INFO("Got %d and %d", *out1, *out2);
+}
+
+int main(int argc, char* argv[])
+
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ e.load_platform(argv[1]);
+ simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker);
+ e.run();
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+p Testing the wait_all_for feature of S4U
+
+! output sort 19
+$ ${bindir:=.}/wait-all-for ${platfdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
+> [ 0.000000] (1:worker@Tremblay) Sending and receiving 42 and 51 asynchronously
+> [ 0.000000] (1:worker@Tremblay) All comms have started
+> [ 0.500000] (1:worker@Tremblay) wait_all_for: Timeout reached
+> [ 0.500000] (1:worker@Tremblay) wait_all_for: 0 comms finished (#comms=4)
+> [ 1.000000] (1:worker@Tremblay) wait_all_for: Timeout reached
+> [ 1.000000] (1:worker@Tremblay) wait_all_for: 0 comms finished (#comms=4)
+> [ 1.500000] (1:worker@Tremblay) wait_all_for: Timeout reached
+> [ 1.500000] (1:worker@Tremblay) wait_all_for: 1 comms finished (#comms=4)
+> [ 2.000000] (1:worker@Tremblay) wait_all_for: Timeout reached
+> [ 2.000000] (1:worker@Tremblay) wait_all_for: 0 comms finished (#comms=3)
+> [ 2.070331] (1:worker@Tremblay) wait_all_for: 3 comms finished (#comms=3)
+> [ 2.070331] (1:worker@Tremblay) All comms have finished
+> [ 2.070331] (1:worker@Tremblay) Got 42 and 51