Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert get-sender test
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 30 Mar 2020 10:41:55 +0000 (12:41 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 30 Mar 2020 11:03:35 +0000 (13:03 +0200)
MANIFEST.in
src/s4u/s4u_Comm.cpp
teshsuite/msg/CMakeLists.txt
teshsuite/msg/get_sender/get_sender.c [deleted file]
teshsuite/s4u/CMakeLists.txt
teshsuite/s4u/comm-get-sender/comm-get-sender.cpp [new file with mode: 0644]
teshsuite/s4u/comm-get-sender/comm-get-sender.tesh [moved from teshsuite/msg/get_sender/get_sender.tesh with 73% similarity]

index c6627be..c5d7fa8 100644 (file)
@@ -660,8 +660,6 @@ include teshsuite/mc/random-bug/random-bug-nocrash.tesh
 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
@@ -692,6 +690,8 @@ include teshsuite/s4u/cloud-sharing/cloud-sharing.cpp
 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
index 3b192c3..4d5bb78 100644 (file)
@@ -249,12 +249,10 @@ Mailbox* Comm::get_mailbox() const
 
 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
index cc01ff0..765e69c 100644 (file)
@@ -1,4 +1,4 @@
-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)
@@ -14,7 +14,7 @@ set(teshsuite_src ${teshsuite_src}  PARENT_SCOPE)
 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}
diff --git a/teshsuite/msg/get_sender/get_sender.c b/teshsuite/msg/get_sender/get_sender.c
deleted file mode 100644 (file)
index 968fefd..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* 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;
-}
index 80e5431..03487a5 100644 (file)
@@ -1,6 +1,6 @@
 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
@@ -25,7 +25,7 @@ set_property(TARGET activity-lifecycle APPEND PROPERTY INCLUDE_DIRECTORIES "${IN
 ## 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)
diff --git a/teshsuite/s4u/comm-get-sender/comm-get-sender.cpp b/teshsuite/s4u/comm-get-sender/comm-get-sender.cpp
new file mode 100644 (file)
index 0000000..5ffdce4
--- /dev/null
@@ -0,0 +1,44 @@
+/* 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;
+}
@@ -1,5 +1,5 @@
 ! 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'