From 458ff11a751f4b2d4af11acb4eff8c720fcaeb91 Mon Sep 17 00:00:00 2001 From: adfaure Date: Mon, 18 Jul 2016 15:23:52 +0200 Subject: [PATCH 1/1] [s4u] Mailbox::receiver return a s4u::ActorPtr --- include/simgrid/s4u/mailbox.hpp | 2 +- src/s4u/s4u_mailbox.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/simgrid/s4u/mailbox.hpp b/include/simgrid/s4u/mailbox.hpp index 4238ecfd02..c4a022c9d6 100644 --- a/include/simgrid/s4u/mailbox.hpp +++ b/include/simgrid/s4u/mailbox.hpp @@ -61,7 +61,7 @@ public: void setReceiver(Actor* process); /** Return the process declared as permanent receiver, or nullptr if none **/ - Actor& receiver(); + ActorPtr receiver(); }; using MailboxPtr = Mailbox::Ptr; diff --git a/src/s4u/s4u_mailbox.cpp b/src/s4u/s4u_mailbox.cpp index d7f48697dc..ed93710d70 100644 --- a/src/s4u/s4u_mailbox.cpp +++ b/src/s4u/s4u_mailbox.cpp @@ -43,8 +43,9 @@ void Mailbox::setReceiver(Actor* actor) { } /** @brief get the receiver (process associated to the mailbox) */ -Actor& Mailbox::receiver() { - return pimpl_->permanent_receiver->actor(); +ActorPtr Mailbox::receiver() { + if(pimpl_->permanent_receiver == nullptr) return ActorPtr(); + return ActorPtr(&pimpl_->permanent_receiver->actor()); } } @@ -62,5 +63,5 @@ void sg_mbox_setReceiver(sg_mbox_t mbox, smx_process_t process) { mbox->setReceiver(&process->actor()); } smx_process_t sg_mbox_receiver(sg_mbox_t mbox) { - return mbox->receiver().getInferior(); + return mbox->receiver()->getInferior(); } -- 2.20.1