Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add sg_comm_wait()
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 24 Feb 2020 11:35:25 +0000 (12:35 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 24 Feb 2020 11:35:25 +0000 (12:35 +0100)
+ unref comm is test return true

include/simgrid/comm.h
src/s4u/s4u_Comm.cpp

index e630676..e8dfcd9 100644 (file)
@@ -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);
index c2dc1f1..bf135b4 100644 (file)
@@ -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)