From 0ce363d7431c7d5bfdadf74b8599c4ec348c82cd Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 31 Jul 2016 17:54:15 +0200 Subject: [PATCH] change a false simcall to a s4u call --- include/simgrid/s4u/mailbox.hpp | 5 ++++- include/simgrid/simix.h | 1 - src/msg/msg_gos.cpp | 2 +- src/msg/msg_mailbox.cpp | 2 +- src/s4u/s4u_mailbox.cpp | 13 ++++++++++--- src/simix/libsmx.cpp | 11 ----------- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/include/simgrid/s4u/mailbox.hpp b/include/simgrid/s4u/mailbox.hpp index 63864ad003..eea3e9044b 100644 --- a/include/simgrid/s4u/mailbox.hpp +++ b/include/simgrid/s4u/mailbox.hpp @@ -30,7 +30,7 @@ XBT_PUBLIC_CLASS Mailbox { friend simgrid::s4u::Engine; friend simgrid::simix::Mailbox; - smx_mailbox_t pimpl_; + simgrid::simix::Mailbox *pimpl_; Mailbox(smx_mailbox_t mbox): pimpl_(mbox) {} @@ -51,6 +51,9 @@ public: /** Returns whether the mailbox contains queued communications */ bool empty(); + /** Returns the first element in the queue, or nullptr if none is there */ + smx_synchro_t front(); + /** Declare that the specified process is a permanent receiver on that mailbox * * It means that the communications sent to this mailbox will start flowing to its host even before he does a recv(). diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 95edc8c321..0deec819e2 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -320,7 +320,6 @@ XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration); /***** Rendez-vous points *****/ XBT_PUBLIC(smx_mailbox_t) simcall_mbox_create(const char *name); -XBT_PUBLIC(smx_synchro_t) simcall_mbox_front(smx_mailbox_t mbox); XBT_PUBLIC(void) simcall_mbox_set_receiver(smx_mailbox_t mbox , smx_process_t process); /***** Communication simcalls *****/ diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 1d0131f5c1..50ea058216 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -852,7 +852,7 @@ int MSG_task_listen(const char *alias) int MSG_task_listen_from(const char *alias) { msg_mailbox_t mbox = MSG_mailbox_get_by_alias(alias); - simgrid::kernel::activity::Comm* comm = static_cast(simcall_mbox_front(mbox->getImpl())); + simgrid::kernel::activity::Comm* comm = static_cast(mbox->front()); if (!comm) return -1; diff --git a/src/msg/msg_mailbox.cpp b/src/msg/msg_mailbox.cpp index a6b8057460..aa96e60553 100644 --- a/src/msg/msg_mailbox.cpp +++ b/src/msg/msg_mailbox.cpp @@ -21,7 +21,7 @@ int MSG_mailbox_is_empty(msg_mailbox_t mailbox) msg_task_t MSG_mailbox_front(msg_mailbox_t mailbox) { - simgrid::kernel::activity::Comm* comm = static_cast(simcall_mbox_front(mailbox->getImpl())); + simgrid::kernel::activity::Comm* comm = static_cast(mailbox->front()); if (!comm) return nullptr; diff --git a/src/s4u/s4u_mailbox.cpp b/src/s4u/s4u_mailbox.cpp index c87c3808ed..3f289d8425 100644 --- a/src/s4u/s4u_mailbox.cpp +++ b/src/s4u/s4u_mailbox.cpp @@ -21,7 +21,8 @@ const char *Mailbox::getName() { return pimpl_->name; } -MailboxPtr Mailbox::byName(const char*name) { +MailboxPtr Mailbox::byName(const char*name) +{ // FIXME: there is a race condition here where two actors run Mailbox::byName // on a non-existent mailbox during the same scheduling round. Both will be // interrupted in the simcall creating the underlying simix mbox. @@ -34,8 +35,14 @@ MailboxPtr Mailbox::byName(const char*name) { return MailboxPtr(&mbox->piface_, true); } -bool Mailbox::empty() { - return nullptr == simcall_mbox_front(pimpl_); +bool Mailbox::empty() +{ + return pimpl_->comm_queue.empty(); +} + +smx_synchro_t Mailbox::front() +{ + return pimpl_->comm_queue.empty() ? nullptr : pimpl_->comm_queue.front(); } void Mailbox::setReceiver(Actor* actor) { diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index dfbd77575b..e812dd7a7f 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -621,17 +621,6 @@ smx_mailbox_t simcall_mbox_create(const char *name) return simcall_BODY_mbox_create(name); } -/** - * \ingroup simix_mbox_management - * \brief returns the communication at the head of the rendez-vous - * \param mbox The rendez-vous point - * \return The communication or nullptr if empty - */ -smx_synchro_t simcall_mbox_front(smx_mailbox_t mbox) -{ - return mbox->comm_queue.empty() ? nullptr : mbox->comm_queue.front(); -} - void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process) { simcall_BODY_mbox_set_receiver(mbox, process); -- 2.20.1