Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "We never use the name of the mailbox"
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 23 Apr 2016 21:01:36 +0000 (23:01 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 23 Apr 2016 21:01:36 +0000 (23:01 +0200)
Actually, MC use the name of the mailbox for some reason.

This reverts commit cd1b6fc186f641dd5e3fb68d793c6253e1b8fcd9.

include/simgrid/s4u/mailbox.hpp
src/s4u/s4u_mailbox.cpp
src/simix/smx_network.cpp
src/simix/smx_network_private.h

index 2a75091..4b8011c 100644 (file)
@@ -3,8 +3,6 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifdef __cplusplus
-
 #ifndef SIMGRID_S4U_MAILBOX_HPP
 #define SIMGRID_S4U_MAILBOX_HPP
 
@@ -36,18 +34,21 @@ protected:
   smx_mailbox_t getInferior() { return inferior_; }
 
 public:
+  /** Get the name of that mailbox */
+  const char *getName();
   /** Retrieve the mailbox associated to the given string */
   static Mailbox *byName(const char *name);
   /** Returns whether the mailbox contains queued communications */
   bool empty();
 
 private:
+  std::string name_;
   smx_mailbox_t inferior_;
   static boost::unordered_map<std::string, Mailbox *> *mailboxes;
 };
 }} // namespace simgrid::s4u
 
-#endif
+#endif /* C++ */
 
 XBT_PUBLIC(sg_mbox_t) sg_mbox_by_name(const char*name);
 XBT_PUBLIC(int) sg_mbox_is_empty(sg_mbox_t mbox);
index 6e497d8..c057113 100644 (file)
@@ -20,8 +20,12 @@ boost::unordered_map <std::string, s4u::Mailbox *> *s4u::Mailbox::mailboxes = ne
 
 s4u::Mailbox::Mailbox(const char*name, smx_mailbox_t inferior) {
   inferior_ = inferior;
+  name_ = name;
   mailboxes->insert({name, this});
 }
+const char *s4u::Mailbox::getName() {
+  return name_.c_str();
+}
 s4u::Mailbox *s4u::Mailbox::byName(const char*name) {
   s4u::Mailbox *res;
   try {
index 724dc20..dcf2c73 100644 (file)
@@ -41,12 +41,13 @@ smx_mailbox_t SIMIX_mbox_create(const char *name)
 
   if (!mbox) {
     mbox = xbt_new0(s_smx_mailbox_t, 1);
+    mbox->name = xbt_strdup(name);
     mbox->comm_queue = new std::deque<smx_synchro_t>();
     mbox->done_comm_queue = nullptr; // Allocated on need only
     mbox->permanent_receiver=NULL;
 
     XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name);
-    xbt_dict_set(mailboxes, name, mbox, NULL);
+    xbt_dict_set(mailboxes, mbox->name, mbox, NULL);
   }
   return mbox;
 }
@@ -55,6 +56,7 @@ void SIMIX_mbox_free(void *data)
 {
   XBT_DEBUG("mbox free %p", data);
   smx_mailbox_t mbox = (smx_mailbox_t) data;
+  xbt_free(mbox->name);
   delete mbox->comm_queue;
   delete mbox->done_comm_queue;
 
index 5c6adf8..cc6e381 100644 (file)
@@ -15,6 +15,7 @@
 
 /** @brief Rendez-vous point datatype */
 typedef struct s_smx_mailbox {
+  char *name;
   std::deque<smx_synchro_t> *comm_queue;
   void *data;
   smx_process_t permanent_receiver; //process which the mailbox is attached to