From a08884c0afcf5031a7bae9b28c47de8572c91f19 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 16 Aug 2015 18:38:47 +0200 Subject: [PATCH] adapt to the new simcall_comm_recv() prototype --- include/simgrid/s4u/comm.hpp | 6 ++---- src/s4u/s4u_actor.cpp | 2 +- src/s4u/s4u_comm.cpp | 9 +++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/simgrid/s4u/comm.hpp b/include/simgrid/s4u/comm.hpp index c2d3a59e17..bf0f7cb675 100644 --- a/include/simgrid/s4u/comm.hpp +++ b/include/simgrid/s4u/comm.hpp @@ -30,7 +30,7 @@ public: /** Creates and start an async send to the mailbox #dest */ static Comm &send_async(s4u::Actor *sender, Mailbox &dest, void *data, int simulatedByteAmount); /** Creates (but don't start) an async recv onto the mailbox #from */ - static Comm &recv_init(Mailbox &from); + static Comm &recv_init(s4u::Actor *receiver, Mailbox &from); /** Creates and start an async recv to the mailbox #from */ //static Comm &recv_async(Mailbox &from, void *data); @@ -71,11 +71,9 @@ private: /* FIXME: expose these elements in the API */ void (*p_cleanFunction)(void *) = NULL; void (*p_copyDataFunction)(smx_synchro_t, void*, size_t) = NULL; - - - private: Actor *p_sender = NULL; + Actor *p_receiver = NULL; Mailbox *p_mailbox = NULL; }; diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 74264b5533..879d21e530 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -85,7 +85,7 @@ void s4u::Actor::execute(double flops) { char *s4u::Actor::recvstr(Mailbox &chan) { void *res=NULL; - Comm c = Comm::recv_init(chan); + Comm c = Comm::recv_init(this, chan); c.setDstData(&res,sizeof(res)); c.wait(); diff --git a/src/s4u/s4u_comm.cpp b/src/s4u/s4u_comm.cpp index 44f526e270..e24b4ec342 100644 --- a/src/s4u/s4u_comm.cpp +++ b/src/s4u/s4u_comm.cpp @@ -24,8 +24,9 @@ s4u::Comm &s4u::Comm::send_init(s4u::Actor *sender, s4u::Mailbox &chan) { return *res; } -s4u::Comm &s4u::Comm::recv_init(s4u::Mailbox &chan) { +s4u::Comm &s4u::Comm::recv_init(s4u::Actor *receiver, s4u::Mailbox &chan) { s4u::Comm *res = new s4u::Comm(); + res->p_receiver = receiver; res->p_mailbox = &chan; return *res; @@ -78,7 +79,7 @@ void s4u::Comm::start() { p_matchFunction, p_cleanFunction, p_copyDataFunction, p_userData, p_detached); } else if (p_dstBuff != NULL) { // Receiver side - p_inferior = simcall_comm_irecv(p_mailbox->getInferior(), p_dstBuff, &p_dstBuffSize, + p_inferior = simcall_comm_irecv(p_receiver->getInferior(), p_mailbox->getInferior(), p_dstBuff, &p_dstBuffSize, p_matchFunction, p_copyDataFunction, p_userData, p_rate); @@ -99,7 +100,7 @@ void s4u::Comm::wait() { p_matchFunction, p_copyDataFunction, p_userData, -1 /*timeout*/); } else { - simcall_comm_recv(p_mailbox->getInferior(), p_dstBuff, &p_dstBuffSize, + simcall_comm_recv(p_receiver->getInferior(), p_mailbox->getInferior(), p_dstBuff, &p_dstBuffSize, p_matchFunction, p_copyDataFunction, p_userData, -1/*timeout*/, p_rate); } @@ -122,7 +123,7 @@ void s4u::Comm::wait(double timeout) { p_matchFunction, p_copyDataFunction, p_userData, timeout); } else { // Receiver - simcall_comm_recv(p_mailbox->getInferior(), p_dstBuff, &p_dstBuffSize, + simcall_comm_recv(p_receiver->getInferior(), p_mailbox->getInferior(), p_dstBuff, &p_dstBuffSize, p_matchFunction, p_copyDataFunction, p_userData, timeout, p_rate); } -- 2.20.1