From 8885dc88b96967757ee901950a7f9b8eef96bc6f Mon Sep 17 00:00:00 2001 From: adfaure Date: Wed, 20 Jul 2016 10:14:25 +0200 Subject: [PATCH] [s4u] add Comm::test --- include/simgrid/s4u/comm.hpp | 2 ++ src/s4u/s4u_comm.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/simgrid/s4u/comm.hpp b/include/simgrid/s4u/comm.hpp index 47c7332c91..2929750de8 100644 --- a/include/simgrid/s4u/comm.hpp +++ b/include/simgrid/s4u/comm.hpp @@ -56,6 +56,8 @@ public: /** Retrieve the size of the received data */ size_t getDstDataSize(); + bool test(); + private: double rate_ = -1; diff --git a/src/s4u/s4u_comm.cpp b/src/s4u/s4u_comm.cpp index 591040574a..401a6c2b80 100644 --- a/src/s4u/s4u_comm.cpp +++ b/src/s4u/s4u_comm.cpp @@ -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; +} + } } -- 2.20.1