Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
stringify s4u::Mailbox and k::a::MailboxImpl
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 13 Jul 2018 20:03:23 +0000 (22:03 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 13 Jul 2018 20:03:23 +0000 (22:03 +0200)
include/simgrid/s4u/Mailbox.hpp
src/kernel/activity/MailboxImpl.cpp
src/kernel/activity/MailboxImpl.hpp
src/s4u/s4u_Mailbox.cpp

index ab4db6d..acce469 100644 (file)
@@ -122,10 +122,7 @@ public:
   /** @brief Retrieves the name of that mailbox as a C string */
   const char* get_cname() const;
 
   /** @brief Retrieves the name of that mailbox as a C string */
   const char* get_cname() const;
 
-  /** Retrieve the mailbox associated to the given C string */
-  static MailboxPtr by_name(const char* name);
-
-  /** Retrieve the mailbox associated to the given C++ string */
+  /** Retrieve the mailbox associated to the given name */
   static MailboxPtr by_name(std::string name);
 
   /** Returns whether the mailbox contains queued communications */
   static MailboxPtr by_name(std::string name);
 
   /** Returns whether the mailbox contains queued communications */
index 647c643..ebf615e 100644 (file)
@@ -25,7 +25,7 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 /** @brief Returns the mailbox of that name, or nullptr */
 namespace kernel {
 namespace activity {
 /** @brief Returns the mailbox of that name, or nullptr */
-MailboxImpl* MailboxImpl::byNameOrNull(const char* name)
+MailboxImpl* MailboxImpl::byNameOrNull(std::string name)
 {
   auto mbox = mailboxes->find(name);
   if (mbox != mailboxes->end())
 {
   auto mbox = mailboxes->find(name);
   if (mbox != mailboxes->end())
@@ -34,14 +34,13 @@ MailboxImpl* MailboxImpl::byNameOrNull(const char* name)
     return nullptr;
 }
 /** @brief Returns the mailbox of that name, newly created on need */
     return nullptr;
 }
 /** @brief Returns the mailbox of that name, newly created on need */
-MailboxImpl* MailboxImpl::byNameOrCreate(const char* name)
+MailboxImpl* MailboxImpl::byNameOrCreate(std::string name)
 {
 {
-  xbt_assert(name, "Mailboxes must have a name");
   /* two processes may have pushed the same mbox_create simcall at the same time */
   auto m = mailboxes->find(name);
   if (m == mailboxes->end()) {
     smx_mailbox_t mbox = new MailboxImpl(name);
   /* two processes may have pushed the same mbox_create simcall at the same time */
   auto m = mailboxes->find(name);
   if (m == mailboxes->end()) {
     smx_mailbox_t mbox = new MailboxImpl(name);
-    XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name);
+    XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name.c_str());
     (*mailboxes)[mbox->name_] = mbox;
     return mbox;
   } else
     (*mailboxes)[mbox->name_] = mbox;
     return mbox;
   } else
index bfd5baf..b965ea5 100644 (file)
@@ -21,7 +21,7 @@ namespace activity {
 /** @brief Implementation of the simgrid::s4u::Mailbox */
 
 class MailboxImpl {
 /** @brief Implementation of the simgrid::s4u::Mailbox */
 
 class MailboxImpl {
-  explicit MailboxImpl(const char* name)
+  explicit MailboxImpl(std::string name)
       : piface_(this), name_(name), comm_queue(MAX_MAILBOX_SIZE), done_comm_queue(MAX_MAILBOX_SIZE)
   {
   }
       : piface_(this), name_(name), comm_queue(MAX_MAILBOX_SIZE), done_comm_queue(MAX_MAILBOX_SIZE)
   {
   }
@@ -29,8 +29,8 @@ class MailboxImpl {
 public:
   const simgrid::xbt::string& get_name() const { return name_; }
   const char* get_cname() const { return name_.c_str(); }
 public:
   const simgrid::xbt::string& get_name() const { return name_; }
   const char* get_cname() const { return name_.c_str(); }
-  static MailboxImpl* byNameOrNull(const char* name);
-  static MailboxImpl* byNameOrCreate(const char* name);
+  static MailboxImpl* byNameOrNull(std::string name);
+  static MailboxImpl* byNameOrCreate(std::string name);
   void setReceiver(s4u::ActorPtr actor);
   void push(activity::CommImplPtr comm);
   void remove(smx_activity_t activity);
   void setReceiver(s4u::ActorPtr actor);
   void push(activity::CommImplPtr comm);
   void remove(smx_activity_t activity);
index 0170e6f..03c12aa 100644 (file)
@@ -24,7 +24,7 @@ const char* Mailbox::get_cname() const
   return pimpl_->get_cname();
 }
 
   return pimpl_->get_cname();
 }
 
-MailboxPtr Mailbox::by_name(const char* name)
+MailboxPtr Mailbox::by_name(std::string name)
 {
   kernel::activity::MailboxImpl* mbox = kernel::activity::MailboxImpl::byNameOrNull(name);
   if (mbox == nullptr) {
 {
   kernel::activity::MailboxImpl* mbox = kernel::activity::MailboxImpl::byNameOrNull(name);
   if (mbox == nullptr) {
@@ -33,11 +33,6 @@ MailboxPtr Mailbox::by_name(const char* name)
   return MailboxPtr(&mbox->piface_, true);
 }
 
   return MailboxPtr(&mbox->piface_, true);
 }
 
-MailboxPtr Mailbox::by_name(std::string name)
-{
-  return by_name(name.c_str());
-}
-
 bool Mailbox::empty()
 {
   return pimpl_->comm_queue.empty();
 bool Mailbox::empty()
 {
   return pimpl_->comm_queue.empty();