Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
no need for the sendstr() pimple. use send() instead
[simgrid.git] / src / s4u / s4u_actor.cpp
index 8d4f299..04544a0 100644 (file)
@@ -4,13 +4,14 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "../../include/simgrid/s4u/actor.hpp"
-#include "../../include/simgrid/s4u/mailbox.hpp"
 #include "xbt/log.h"
 #include "msg/msg_private.h"
 #include "msg/msg_mailbox.h"
 
+#include "simgrid/s4u/actor.hpp"
+#include "simgrid/s4u/comm.hpp"
 #include "simgrid/s4u/host.hpp"
+#include "simgrid/s4u/mailbox.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor,"S4U actors");
 
@@ -81,19 +82,22 @@ void s4u::Actor::execute(double flops) {
        simcall_process_execute(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
 }
 
-char *s4u::Actor::recvstr(Mailbox &chan) {
-       char *res=NULL;
-       size_t res_size=sizeof(res);
+void *s4u::Actor::recv(Mailbox &chan) {
+       void *res=NULL;
 
-       simcall_comm_recv(chan.getInferior(),&res,&res_size,NULL,NULL,NULL,-1 /* timeout */,-1 /*rate*/);
+       Comm c = Comm::recv_init(this, chan);
+       c.setDstData(&res,sizeof(res));
+       c.wait();
 
     return res;
 }
-void s4u::Actor::sendstr(Mailbox &chan, const char*msg) {
-       char *msg_cpy=xbt_strdup(msg);
-       smx_synchro_t comm = simcall_comm_isend(p_smx_process, chan.getInferior(), strlen(msg),
-                       -1/*rate*/, msg_cpy, sizeof(void *),
-                       NULL, NULL, NULL,NULL/*data*/, 0);
-       simcall_comm_wait(comm, -1/*timeout*/);
+void s4u::Actor::send(Mailbox &chan, void *payload, size_t simulatedSize) {
+       Comm c = Comm::send_init(this,chan);
+       c.setRemains(simulatedSize);
+       c.setSrcData(payload);
+       c.wait();
 }
 
+s4u::Comm &s4u::Actor::send_init(Mailbox &chan) {
+       return s4u::Comm::send_init(this, chan);
+}