Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please henri, add recv with timeout.
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 3 Jul 2017 15:58:45 +0000 (17:58 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 3 Jul 2017 15:58:45 +0000 (17:58 +0200)
include/simgrid/s4u/Actor.hpp
src/s4u/s4u_actor.cpp

index 5b0378c..524f508 100644 (file)
@@ -313,6 +313,7 @@ template <class Rep, class Period> inline void sleep_for(std::chrono::duration<R
    * See \ref Comm for the full communication API (including non blocking communications).
    */
   XBT_PUBLIC(void*) recv(MailboxPtr chan);
+  XBT_PUBLIC(void*) recv(MailboxPtr chan, double timeout);
   XBT_PUBLIC(CommPtr) irecv(MailboxPtr chan, void** data);
 
   /** Block the actor until it delivers a message of the given simulated size to the given mailbox
index ab6f3a1..eb588ca 100644 (file)
@@ -211,6 +211,15 @@ void* recv(MailboxPtr chan) {
   return res;
 }
 
+void* recv(MailboxPtr chan, double timeout)
+{
+  void* res = nullptr;
+  CommPtr c = Comm::recv_init(chan);
+  c->setDstData(&res, sizeof(res));
+  c->wait(timeout);
+  return res;
+}
+
 void send(MailboxPtr chan, void* payload, double simulatedSize)
 {
   CommPtr c = Comm::send_init(chan);