From: Frederic Suter Date: Mon, 24 Feb 2020 11:35:25 +0000 (+0100) Subject: add sg_comm_wait() X-Git-Tag: v3.26~906 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d6956e89654083209215c97fe1dc549621204224 add sg_comm_wait() + unref comm is test return true --- diff --git a/include/simgrid/comm.h b/include/simgrid/comm.h index e63067614f..e8dfcd9619 100644 --- a/include/simgrid/comm.h +++ b/include/simgrid/comm.h @@ -13,6 +13,7 @@ SG_BEGIN_DECL XBT_PUBLIC int sg_comm_test(sg_comm_t comm); +XBT_PUBLIC void sg_comm_wait(sg_comm_t comm); XBT_PUBLIC void sg_comm_wait_all(sg_comm_t* comms, size_t count); XBT_PUBLIC int sg_comm_wait_any_for(sg_comm_t* comms, size_t count, double timeout); XBT_PUBLIC int sg_comm_wait_any(sg_comm_t* comms, size_t count); diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index c2dc1f13e9..bf135b4d04 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -257,7 +257,16 @@ Actor* Comm::get_sender() const /* **************************** Public C interface *************************** */ int sg_comm_test(sg_comm_t comm) { - return comm->test(); + bool finished = comm->test(); + if (finished) + comm->unref(); + return finished; +} + +void sg_comm_wait(sg_comm_t comm) +{ + comm->wait_for(-1); + comm->unref(); } void sg_comm_wait_all(sg_comm_t* comms, size_t count)