Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[s4u] replace smx_process_t by Actor in Mailbox::setReceiver() & Mailbox::receiver()
authoradfaure <adrien.faure2@gmail.com>
Fri, 1 Jul 2016 09:53:23 +0000 (11:53 +0200)
committeradfaure <adrien.faure2@gmail.com>
Fri, 1 Jul 2016 09:53:23 +0000 (11:53 +0200)
include/simgrid/s4u/actor.hpp
include/simgrid/s4u/mailbox.hpp
src/s4u/s4u_actor.cpp
src/s4u/s4u_mailbox.cpp

index 52c7286..f7c43b8 100644 (file)
@@ -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<class F, class... Args>
@@ -232,7 +234,8 @@ public:
   static void killAll();
 
   bool valid() const { return pimpl_ != nullptr; }
-
+  
+  smx_process_t getInferior();
 private:
   smx_process_t pimpl_ = nullptr;
 };
index 3d1b6ab..cbaf3fa 100644 (file)
@@ -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_;
index 63907cf..35b65f6 100644 (file)
@@ -77,6 +77,11 @@ void Actor::kill(int pid) {
   }
 }
 
+smx_process_t Actor::getInferior() {
+  return pimpl_;
+}
+
+
 void Actor::kill() {
   simcall_process_kill(pimpl_);
 }
index c23816f..f4c43dc 100644 (file)
@@ -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();
 }