Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change a false simcall to a s4u call
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 31 Jul 2016 15:54:15 +0000 (17:54 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 31 Jul 2016 15:54:15 +0000 (17:54 +0200)
include/simgrid/s4u/mailbox.hpp
include/simgrid/simix.h
src/msg/msg_gos.cpp
src/msg/msg_mailbox.cpp
src/s4u/s4u_mailbox.cpp
src/simix/libsmx.cpp

index 63864ad..eea3e90 100644 (file)
@@ -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().
index 95edc8c..0deec81 100644 (file)
@@ -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 *****/
index 1d0131f..50ea058 100644 (file)
@@ -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<simgrid::kernel::activity::Comm*>(simcall_mbox_front(mbox->getImpl()));
+  simgrid::kernel::activity::Comm* comm = static_cast<simgrid::kernel::activity::Comm*>(mbox->front());
 
   if (!comm)
     return -1;
index a6b8057..aa96e60 100644 (file)
@@ -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<simgrid::kernel::activity::Comm*>(simcall_mbox_front(mailbox->getImpl()));
+  simgrid::kernel::activity::Comm* comm = static_cast<simgrid::kernel::activity::Comm*>(mailbox->front());
 
   if (!comm)
     return nullptr;
index c87c380..3f289d8 100644 (file)
@@ -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) {
index dfbd775..e812dd7 100644 (file)
@@ -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);