Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a Mailbox::byName(std::string) function
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 12 Aug 2016 21:12:50 +0000 (23:12 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 12 Aug 2016 21:12:50 +0000 (23:12 +0200)
examples/s4u/launching/s4u_launching.cpp
include/simgrid/s4u/mailbox.hpp
src/s4u/s4u_mailbox.cpp

index bad8098..3c9b931 100644 (file)
@@ -68,7 +68,7 @@ public:
     /* This constructor is used when we pass parameters to the actor */
     /* as with argc/argv, args[0] is the actor's name, so the first parameter is args[1] */
     if (args.size() > 1)
-      mailbox = simgrid::s4u::Mailbox::byName(args[1].c_str());
+      mailbox = simgrid::s4u::Mailbox::byName(args[1]);
   }
   void operator()() {
     XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->getName());
index 6298ad3..e68b46d 100644 (file)
@@ -32,19 +32,22 @@ XBT_PUBLIC_CLASS Mailbox {
 
   Mailbox(smx_mailbox_t mbox): pimpl_(mbox) {}
 
-public:
-  smx_mailbox_t getImpl() { return pimpl_; } // FIXME: make me protected
-
   // We don't have to manage the lifetime of mailboxes:
   friend void intrusive_ptr_add_ref(Mailbox*) {}
   friend void intrusive_ptr_release(Mailbox*) {}
+public:
+  smx_mailbox_t getImpl() { return pimpl_; } // FIXME: make me protected
+
 
   /** Get the name of that mailbox */
   const char *getName();
 
-  /** Retrieve the mailbox associated to the given string */
+  /** Retrieve the mailbox associated to the given string (as a C string) */
   static MailboxPtr byName(const char *name);
 
+  /** Retrieve the mailbox associated to the given string (as a C++ string) */
+  static MailboxPtr byName(std::string name);
+
   /** Returns whether the mailbox contains queued communications */
   bool empty();
 
@@ -53,8 +56,9 @@ public:
 
   /** 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().
-   * This models the real behavior of TCP and MPI communications, amongst other.
+   * It means that the communications sent to this mailbox will start flowing to
+   * its host even before he does a recv(). This models the real behavior of TCP
+   * and MPI communications, amongst other.
    */
   void setReceiver(ActorPtr process);
 
index cff1a5f..6e5f18d 100644 (file)
@@ -34,6 +34,11 @@ MailboxPtr Mailbox::byName(const char*name)
   return MailboxPtr(&mbox->piface_, true);
 }
 
+MailboxPtr Mailbox::byName(std::string name)
+{
+  return byName(name.c_str());
+}
+
 bool Mailbox::empty()
 {
   return pimpl_->comm_queue.empty();