X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1108fc19974fc68a9d079ff07b5d4363bf8b9a8b..d19d875fd0b7da4e10227ee00bc2035b68f60f47:/src/s4u/s4u_actor.cpp diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 571e0ec162..64d429e25b 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -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 "simgrid/s4u/actor.hpp" -#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"); @@ -77,23 +78,27 @@ void s4u::Actor::sleep(double duration) { simcall_process_sleep(duration); } -void s4u::Actor::execute(double flops) { - simcall_process_execute(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/); +e_smx_state_t s4u::Actor::execute(double flops) { + smx_synchro_t s = simcall_process_execute(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/); + return simcall_process_execution_wait(s); } -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); +}