X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0921a44d5521b3337b8752aa2a9f06ee1405fb24..f1e469ce075c0a1ad21a7fd0fdb587f9a3cb5289:/src/s4u/s4u_mailbox.cpp diff --git a/src/s4u/s4u_mailbox.cpp b/src/s4u/s4u_mailbox.cpp index 9e5f3f4c9c..2e6ad2c88a 100644 --- a/src/s4u/s4u_mailbox.cpp +++ b/src/s4u/s4u_mailbox.cpp @@ -22,10 +22,10 @@ const char *Mailbox::name() { MailboxPtr Mailbox::byName(const char*name) { - simix::MailboxImpl* mbox = simix::MailboxImpl::byNameOrNull(name); + kernel::activity::MailboxImpl* mbox = kernel::activity::MailboxImpl::byNameOrNull(name); if (mbox == nullptr) { mbox = simix::kernelImmediate([name] { - return simix::MailboxImpl::byNameOrCreate(name); + return kernel::activity::MailboxImpl::byNameOrCreate(name); }); } return MailboxPtr(&mbox->piface_, true); @@ -41,20 +41,27 @@ bool Mailbox::empty() return pimpl_->comm_queue.empty(); } +bool Mailbox::listen() +{ + return !this->empty() || (pimpl_->permanent_receiver && !pimpl_->done_comm_queue.empty()); +} + smx_activity_t Mailbox::front() { return pimpl_->comm_queue.empty() ? nullptr : pimpl_->comm_queue.front(); } void Mailbox::setReceiver(ActorPtr actor) { - simcall_mbox_set_receiver(pimpl_, actor == nullptr ? nullptr : actor->pimpl_); + simix::kernelImmediate([this, actor]() { + this->pimpl_->setReceiver(actor); + }); } /** @brief get the receiver (process associated to the mailbox) */ ActorPtr Mailbox::receiver() { - if(pimpl_->permanent_receiver == nullptr) + if (pimpl_->permanent_receiver == nullptr) return ActorPtr(); - return ActorPtr(&pimpl_->permanent_receiver->getIface()); + return pimpl_->permanent_receiver->iface(); } }