From 7bf5d20e2f3b137f0b08f437849834bc15984298 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 4 Apr 2017 09:30:18 +0200 Subject: [PATCH 1/1] add send with timeout and irecv to this_actor API --- include/simgrid/s4u/Actor.hpp | 2 ++ src/s4u/s4u_actor.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 28b24912e9..c158e9de9d 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -302,12 +302,14 @@ namespace this_actor { * See \ref Comm for the full communication API (including non blocking communications). */ XBT_PUBLIC(void*) recv(MailboxPtr chan); + XBT_PUBLIC(Comm&) irecv(MailboxPtr chan, void** data); /** Block the actor until it delivers a message of the given simulated size to the given mailbox * * See \ref Comm for the full communication API (including non blocking communications). */ XBT_PUBLIC(void) send(MailboxPtr chan, void* payload, double simulatedSize); + XBT_PUBLIC(void) send(MailboxPtr chan, void* payload, double simulatedSize, double timeout); XBT_PUBLIC(Comm&) isend(MailboxPtr chan, void* payload, double simulatedSize); diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 895913597f..570c181284 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -190,11 +190,25 @@ void send(MailboxPtr chan, void* payload, double simulatedSize) c.wait(); } +void send(MailboxPtr chan, void* payload, double simulatedSize, double timeout) +{ + Comm& c = Comm::send_init(chan); + c.setRemains(simulatedSize); + c.setSrcData(payload); + // c.start() is optional. + c.wait(timeout); +} + Comm& isend(MailboxPtr chan, void* payload, double simulatedSize) { return Comm::send_async(chan, payload, simulatedSize); } +Comm& isend(MailboxPtr chan, void** data) +{ + return Comm::recv_async(chan, data); +} + int pid() { return SIMIX_process_self()->pid; -- 2.20.1