From 38d7ddd9ebe710d47e5736787a0969f229d2f1b1 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 16 Aug 2015 18:51:25 +0200 Subject: [PATCH] no need for the sendstr() pimple. use send() instead --- examples/s4u/dumb/s4u_test.cpp | 3 ++- include/simgrid/s4u/actor.hpp | 4 ++-- src/s4u/s4u_actor.cpp | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/s4u/dumb/s4u_test.cpp b/examples/s4u/dumb/s4u_test.cpp index 41559b6488..678d16fd8c 100644 --- a/examples/s4u/dumb/s4u_test.cpp +++ b/examples/s4u/dumb/s4u_test.cpp @@ -31,8 +31,9 @@ public: : Actor(procname,host,argc,argv){} int main(int argc, char **argv) { + const char *msg = "GaBuZoMeu"; XBT_INFO("Hello s4u, I have something to send"); - sendstr(*Mailbox::byName("worker"),"GaBuZoMeu"); + send(*Mailbox::byName("worker"), xbt_strdup(msg), strlen(msg)); XBT_INFO("I'm done. See you."); return 1; diff --git a/include/simgrid/s4u/actor.hpp b/include/simgrid/s4u/actor.hpp index b34a8e9bce..4476f5ef45 100644 --- a/include/simgrid/s4u/actor.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -86,8 +86,8 @@ public: /** Block the actor until it gets a message from the given mailbox */ void *recv(Mailbox &chan); - /** Block the actor until it delivers a string message (that will be copied) to the given mailbox */ - void sendstr(Mailbox &chan, const char*msg); + /** Block the actor until it delivers a message of the given simulated size to the given mailbox */ + void send(Mailbox &chan, void*payload, size_t simulatedSize); /** Creates (but don't start) an async send action */ Comm &send_init(Mailbox &chan); diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index fb3fb0dfda..04544a099e 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -91,10 +91,10 @@ void *s4u::Actor::recv(Mailbox &chan) { return res; } -void s4u::Actor::sendstr(Mailbox &chan, const char*msg) { +void s4u::Actor::send(Mailbox &chan, void *payload, size_t simulatedSize) { Comm c = Comm::send_init(this,chan); - c.setRemains(strlen(msg)); - c.setSrcData(xbt_strdup(msg),sizeof(char*)); + c.setRemains(simulatedSize); + c.setSrcData(payload); c.wait(); } -- 2.20.1