Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
C interface to Comm::wait_any_for
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 3 Feb 2020 15:07:36 +0000 (16:07 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 3 Feb 2020 15:07:36 +0000 (16:07 +0100)
include/simgrid/comm.h [new file with mode: 0644]
src/s4u/s4u_Comm.cpp
tools/cmake/DefinePackages.cmake

diff --git a/include/simgrid/comm.h b/include/simgrid/comm.h
new file mode 100644 (file)
index 0000000..ea808a9
--- /dev/null
@@ -0,0 +1,19 @@
+/* Copyright (c) 2018-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. */
+
+#ifndef INCLUDE_SIMGRID_COMM_H_
+#define INCLUDE_SIMGRID_COMM_H_
+
+#include <simgrid/forward.h>
+#include <xbt/dynar.h>
+
+/* C interface */
+SG_BEGIN_DECL
+
+XBT_PUBLIC int sg_comm_wait_any_for(const xbt_dynar_t comms, double timeout);
+
+SG_END_DECL
+
+#endif /* INCLUDE_SIMGRID_COMM_H_ */
index 8ccb862..670caa5 100644 (file)
@@ -10,6 +10,8 @@
 #include "simgrid/s4u/Comm.hpp"
 #include "simgrid/s4u/Mailbox.hpp"
 
+#include <simgrid/comm.h>
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm, s4u_activity, "S4U asynchronous communications");
 
 namespace simgrid {
@@ -251,3 +253,14 @@ Actor* Comm::get_sender()
 
 } // namespace s4u
 } // namespace simgrid
+/* **************************** Public C interface *************************** */
+int sg_comm_wait_any_for(const xbt_dynar_t comms, double timeout)
+{
+  std::vector<simgrid::s4u::CommPtr> s4u_comms;
+  unsigned int i;
+  sg_comm_t comm;
+  xbt_dynar_foreach (comms, i, comm) {
+    s4u_comms.push_back(comm);
+  }
+  return simgrid::s4u::Comm::wait_any_for(&s4u_comms, timeout);
+}
index 7e411fd..c88566a 100644 (file)
@@ -679,6 +679,7 @@ set(MC_SIMGRID_MC_SRC  src/mc/checker/simgrid_mc.cpp)
 set(headers_to_install
   include/simgrid/actor.h
   include/simgrid/barrier.h
+  include/simgrid/comm.h
   include/simgrid/engine.h
   include/simgrid/Exception.hpp
   include/simgrid/chrono.hpp