include teshsuite/mc/random-bug/random-bug-replay.tesh
include teshsuite/mc/random-bug/random-bug.cpp
include teshsuite/mc/random-bug/random-bug.tesh
-include teshsuite/msg/get_sender/get_sender.c
-include teshsuite/msg/get_sender/get_sender.tesh
include teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c
include teshsuite/msg/task_destroy_cancel/task_destroy_cancel.tesh
include teshsuite/msg/task_listen_from/task_listen_from.c
include teshsuite/s4u/cloud-sharing/cloud-sharing.tesh
include teshsuite/s4u/cloud-two-execs/cloud-two-execs.cpp
include teshsuite/s4u/cloud-two-execs/cloud-two-execs.tesh
+include teshsuite/s4u/comm-get-sender/comm-get-sender.cpp
+include teshsuite/s4u/comm-get-sender/comm-get-sender.tesh
include teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
include teshsuite/s4u/concurrent_rw/concurrent_rw.cpp
include teshsuite/s4u/concurrent_rw/concurrent_rw.tesh
Actor* Comm::get_sender() const
{
- return kernel::actor::simcall([this] {
- kernel::actor::ActorImplPtr sender = nullptr;
- if (pimpl_)
- sender = boost::static_pointer_cast<kernel::activity::CommImpl>(pimpl_)->src_actor_;
- return sender ? sender->ciface() : nullptr;
- });
+ kernel::actor::ActorImplPtr sender = nullptr;
+ if (pimpl_)
+ sender = boost::static_pointer_cast<kernel::activity::CommImpl>(pimpl_)->src_actor_;
+ return sender ? sender->ciface() : nullptr;
}
} // namespace s4u
-foreach(x get_sender task_listen_from task_destroy_cancel)
+foreach(x task_listen_from task_destroy_cancel)
if(enable_msg)
add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set(tesh_files ${tesh_files} PARENT_SCOPE)
if(enable_msg)
- foreach(x get_sender task_destroy_cancel task_listen_from)
+ foreach(x task_destroy_cancel task_listen_from)
ADD_TESH_FACTORIES(tesh-msg-${x} "raw" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
--setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/msg/${x}
+++ /dev/null
-/* Copyright (c) 2009-2020. 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/msg.h"
-#include <float.h>
-XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific to this example");
-
-static int sender_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- XBT_INFO("Sending");
- MSG_task_send(MSG_task_create("Blah", 0.0, 0.0, NULL), MSG_host_get_name(MSG_host_self()));
- MSG_process_sleep(1.0);
- XBT_INFO("Exiting");
- return 0;
-}
-
-static int receiver_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- XBT_INFO("Receiving");
- msg_task_t task = NULL;
- MSG_task_receive_with_timeout(&task, MSG_host_get_name(MSG_host_self()), DBL_MAX);
- xbt_assert(MSG_task_get_sender(task), "No sender received");
- XBT_INFO("Got a message sent by '%s'", MSG_process_get_name(MSG_task_get_sender(task)));
- MSG_process_sleep(2.0);
- XBT_INFO("Did I tell you that I got a message sent by '%s'?", MSG_process_get_name(MSG_task_get_sender(task)));
- MSG_task_destroy(task);
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- MSG_init(&argc, argv);
-
- MSG_create_environment(argv[1]);
-
- MSG_process_create("send", sender_fun, NULL, MSG_get_host_by_name("Tremblay"));
- MSG_process_create("receive", receiver_fun, NULL, MSG_get_host_by_name("Tremblay"));
-
- return MSG_main() != MSG_OK;
-}
foreach(x actor actor-autorestart
activity-lifecycle
- comm-pt2pt wait-any-for
+ comm-get-sender comm-pt2pt wait-any-for
cloud-interrupt-migration cloud-sharing 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
- activity-lifecycle wait-any-for
+ activity-lifecycle comm-get-sender wait-any-for
cloud-interrupt-migration cloud-two-execs concurrent_rw)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
ADD_TESH_FACTORIES(tesh-s4u-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
--- /dev/null
+/* Copyright (c) 2009-2020. 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"
+#include <float.h>
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific to this example");
+
+static void sender_fun()
+{
+ XBT_INFO("Sending");
+ std::string* payload = new std::string("Blah");
+ simgrid::s4u::Mailbox::by_name("Tremblay")->put(payload, 0);
+ simgrid::s4u::this_actor::sleep_for(1.0);
+ XBT_INFO("Exiting");
+}
+
+static void receiver_fun()
+{
+ XBT_INFO("Receiving");
+ void* payload = nullptr;
+ simgrid::s4u::CommPtr comm = simgrid::s4u::Mailbox::by_name("Tremblay")->get_async(&payload);
+ comm->wait();
+ xbt_assert(comm->get_sender(), "No sender received");
+ XBT_INFO("Got a message sent by '%s'", comm->get_sender()->get_cname());
+ simgrid::s4u::this_actor::sleep_for(2.0);
+ XBT_INFO("Did I tell you that I got a message sent by '%s'?", comm->get_sender()->get_cname());
+ delete static_cast<std::string*>(payload);
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+
+ e.load_platform(argv[1]);
+
+ simgrid::s4u::Actor::create("send", simgrid::s4u::Host::by_name("Tremblay"), sender_fun);
+ simgrid::s4u::Actor::create("receive", simgrid::s4u::Host::by_name("Tremblay"), receiver_fun);
+
+ e.run();
+ return 0;
+}
! output sort
-$ ${bindir}/get_sender ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir}/comm-get-sender ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:send@Tremblay) Sending
> [ 0.000000] (2:receive@Tremblay) Receiving
> [ 0.000195] (2:receive@Tremblay) Got a message sent by 'send'