From: adfaure Date: Fri, 1 Jul 2016 09:53:23 +0000 (+0200) Subject: [s4u] replace smx_process_t by Actor in Mailbox::setReceiver() & Mailbox::receiver() X-Git-Tag: v3_14~823 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/90969eea25607f1fd1fd65be04b4a0f77b93621e [s4u] replace smx_process_t by Actor in Mailbox::setReceiver() & Mailbox::receiver() --- diff --git a/include/simgrid/s4u/actor.hpp b/include/simgrid/s4u/actor.hpp index 52c7286841..f7c43b8d2c 100644 --- a/include/simgrid/s4u/actor.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -123,6 +123,8 @@ namespace s4u { /** @brief Simulation Agent (see \ref s4u_actor)*/ XBT_PUBLIC_CLASS Actor { + friend Mailbox; + private: /** Wrap a (possibly non-copyable) single-use task into a `std::function` */ template @@ -232,7 +234,8 @@ public: static void killAll(); bool valid() const { return pimpl_ != nullptr; } - + + smx_process_t getInferior(); private: smx_process_t pimpl_ = nullptr; }; diff --git a/include/simgrid/s4u/mailbox.hpp b/include/simgrid/s4u/mailbox.hpp index 3d1b6abd2e..cbaf3fa7aa 100644 --- a/include/simgrid/s4u/mailbox.hpp +++ b/include/simgrid/s4u/mailbox.hpp @@ -48,9 +48,9 @@ public: * It means that the communications sent to this mailbox will start flowing to its host even before he does a recv(). * This models the real behavior of TCP and MPI communications, amongst other. */ - void setReceiver(smx_process_t process); + void setReceiver(Actor process); /** Return the process declared as permanent receiver, or nullptr if none **/ - smx_process_t receiver(); + Actor receiver(); private: std::string name_; diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 63907cfee3..35b65f6a0a 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -77,6 +77,11 @@ void Actor::kill(int pid) { } } +smx_process_t Actor::getInferior() { + return pimpl_; +} + + void Actor::kill() { simcall_process_kill(pimpl_); } diff --git a/src/s4u/s4u_mailbox.cpp b/src/s4u/s4u_mailbox.cpp index c23816f714..f4c43dcfa0 100644 --- a/src/s4u/s4u_mailbox.cpp +++ b/src/s4u/s4u_mailbox.cpp @@ -45,12 +45,12 @@ bool Mailbox::empty() { return nullptr == simcall_mbox_front(pimpl_); } -void Mailbox::setReceiver(smx_process_t process) { - simcall_mbox_set_receiver(pimpl_, process); +void Mailbox::setReceiver(Actor actor) { + simcall_mbox_set_receiver(pimpl_, actor.pimpl_); } /** @brief get the receiver (process associated to the mailbox) */ -smx_process_t Mailbox::receiver() { - return pimpl_->permanent_receiver; +Actor Mailbox::receiver() { + return Actor(pimpl_->permanent_receiver); } } @@ -68,5 +68,5 @@ void sg_mbox_setReceiver(sg_mbox_t mbox, smx_process_t process) { mbox->setReceiver(process); } smx_process_t sg_mbox_receiver(sg_mbox_t mbox) { - return mbox->receiver(); + return mbox->receiver().getInferior(); }