Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[s4u] add Comm::test
authoradfaure <adrien.faure2@gmail.com>
Wed, 20 Jul 2016 08:14:25 +0000 (10:14 +0200)
committeradfaure <adrien.faure2@gmail.com>
Wed, 20 Jul 2016 08:14:25 +0000 (10:14 +0200)
include/simgrid/s4u/comm.hpp
src/s4u/s4u_comm.cpp

index 47c7332..2929750 100644 (file)
@@ -56,6 +56,8 @@ public:
   /** Retrieve the size of the received data */
   size_t getDstDataSize();
 
+  bool test();
+
 
 private:
   double rate_ = -1;
index 5910405..401a6c2 100644 (file)
@@ -146,5 +146,22 @@ s4u::Comm &Comm::recv_async(Mailbox &dest, void **data) {
   return res;
 }
 
+bool Comm::test() {
+  xbt_assert(state_ == inited || state_ == started || state_ == finished);
+  
+  if (state_ == finished) 
+    xbt_die("Don't call test on a finished comm.");
+  
+  if (state_ == inited) {
+    this->start();
+  }
+  
+  if(simcall_comm_test(pimpl_)){
+    state_ = finished;
+    return true;
+  }
+  return false;
+}
+
 }
 }