From 7c6fac46098c8a91125db191e6ead34770933fc9 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 3 Feb 2020 16:07:36 +0100 Subject: [PATCH] C interface to Comm::wait_any_for --- include/simgrid/comm.h | 19 +++++++++++++++++++ src/s4u/s4u_Comm.cpp | 13 +++++++++++++ tools/cmake/DefinePackages.cmake | 1 + 3 files changed, 33 insertions(+) create mode 100644 include/simgrid/comm.h diff --git a/include/simgrid/comm.h b/include/simgrid/comm.h new file mode 100644 index 0000000000..ea808a9160 --- /dev/null +++ b/include/simgrid/comm.h @@ -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 +#include + +/* 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_ */ diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 8ccb8628d5..670caa547e 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -10,6 +10,8 @@ #include "simgrid/s4u/Comm.hpp" #include "simgrid/s4u/Mailbox.hpp" +#include + 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 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); +} diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 7e411fd572..c88566afd5 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -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 -- 2.20.1