Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Constify getName()/getCname() in s4u::Actor.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 14 Oct 2017 20:11:41 +0000 (22:11 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 14 Oct 2017 21:48:41 +0000 (23:48 +0200)
examples/s4u/actions-comm/s4u-actions-comm.cpp
include/simgrid/s4u/Actor.hpp
src/s4u/s4u_actor.cpp
teshsuite/s4u/actor/actor.cpp
teshsuite/s4u/storage_client_server/storage_client_server.cpp

index 0be93a2..a62e455 100644 (file)
@@ -64,7 +64,7 @@ public:
     double clock                = simgrid::s4u::Engine::getClock();
     simgrid::s4u::MailboxPtr to = simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getName() + "_" + action[2]);
     ACT_DEBUG("Entering Send: %s (size: %g) -- Actor %s on mailbox %s", NAME, size,
     double clock                = simgrid::s4u::Engine::getClock();
     simgrid::s4u::MailboxPtr to = simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getName() + "_" + action[2]);
     ACT_DEBUG("Entering Send: %s (size: %g) -- Actor %s on mailbox %s", NAME, size,
-              simgrid::s4u::this_actor::getName().c_str(), to->getName());
+              simgrid::s4u::this_actor::getCname(), to->getName());
     to->put(payload, size);
     delete payload;
 
     to->put(payload, size);
     delete payload;
 
@@ -77,8 +77,7 @@ public:
     simgrid::s4u::MailboxPtr from =
         simgrid::s4u::Mailbox::byName(std::string(action[2]) + "_" + simgrid::s4u::this_actor::getName());
 
     simgrid::s4u::MailboxPtr from =
         simgrid::s4u::Mailbox::byName(std::string(action[2]) + "_" + simgrid::s4u::this_actor::getName());
 
-    ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME, simgrid::s4u::this_actor::getName().c_str(),
-              from->getName());
+    ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME, simgrid::s4u::this_actor::getCname(), from->getName());
     from->get();
     log_action(action, simgrid::s4u::Engine::getClock() - clock);
   }
     from->get();
     log_action(action, simgrid::s4u::Engine::getClock() - clock);
   }
index 4d2560d..210baad 100644 (file)
@@ -197,10 +197,10 @@ public:
   /** This actor will be automatically terminated when the last non-daemon process finishes **/
   void daemonize();
 
   /** This actor will be automatically terminated when the last non-daemon process finishes **/
   void daemonize();
 
-  /** Retrieves the name of that actor as a C string */
-  const char* getCname();
   /** Retrieves the name of that actor as a C++ string */
   /** Retrieves the name of that actor as a C++ string */
-  simgrid::xbt::string getName();
+  const simgrid::xbt::string& getName() const;
+  /** Retrieves the name of that actor as a C string */
+  const char* getCname() const;
   /** Retrieves the host on which that actor is running */
   s4u::Host* getHost();
   /** Retrieves the PID of that actor
   /** Retrieves the host on which that actor is running */
   s4u::Host* getHost();
   /** Retrieves the PID of that actor
@@ -340,6 +340,9 @@ XBT_PUBLIC(aid_t) getPpid();
 /** @brief Returns the name of the current actor. */
 XBT_PUBLIC(std::string) getName();
 
 /** @brief Returns the name of the current actor. */
 XBT_PUBLIC(std::string) getName();
 
+/** @brief Returns the name of the current actor as a C string. */
+XBT_PUBLIC(const char*) getCname();
+
 /** @brief Returns the name of the host on which the process is running. */
 XBT_PUBLIC(Host*) getHost();
 
 /** @brief Returns the name of the host on which the process is running. */
 XBT_PUBLIC(Host*) getHost();
 
index c5fa2f2..80f0c11 100644 (file)
@@ -85,14 +85,14 @@ void Actor::daemonize()
   simgrid::simix::kernelImmediate([this]() { pimpl_->daemonize(); });
 }
 
   simgrid::simix::kernelImmediate([this]() { pimpl_->daemonize(); });
 }
 
-const char* Actor::getCname()
+const simgrid::xbt::string& Actor::getName() const
 {
 {
-  return this->pimpl_->name.c_str();
+  return this->pimpl_->getName();
 }
 
 }
 
-simgrid::xbt::string Actor::getName()
+const char* Actor::getCname() const
 {
 {
-  return this->pimpl_->name;
+  return this->pimpl_->getCname();
 }
 
 aid_t Actor::getPid()
 }
 
 aid_t Actor::getPid()
@@ -269,7 +269,12 @@ aid_t getPpid()
 
 std::string getName()
 {
 
 std::string getName()
 {
-  return SIMIX_process_self()->name;
+  return SIMIX_process_self()->getName();
+}
+
+const char* getCname()
+{
+  return SIMIX_process_self()->getCname();
 }
 
 Host* getHost()
 }
 
 Host* getHost()
index 948eca2..46b464f 100644 (file)
@@ -26,7 +26,7 @@ static void master()
   simgrid::s4u::this_actor::getHost()->actorList(actor_list);
 
   for (auto const& actor : *actor_list) {
   simgrid::s4u::this_actor::getHost()->actorList(actor_list);
 
   for (auto const& actor : *actor_list) {
-    XBT_INFO("Actor (pid=%lu, ppid=%lu, name=%s)", actor->getPid(), actor->getPpid(), actor->getName().c_str());
+    XBT_INFO("Actor (pid=%lu, ppid=%lu, name=%s)", actor->getPid(), actor->getPpid(), actor->getCname());
     if (simgrid::s4u::this_actor::getPid() != actor->getPid())
       actor->kill();
   }
     if (simgrid::s4u::this_actor::getPid() != actor->getPid())
       actor->kill();
   }
index df64ea9..52a69d7 100644 (file)
@@ -27,7 +27,7 @@ static sg_size_t write_local_file(const char* dest, sg_size_t file_size)
   simgrid::s4u::File* file = new simgrid::s4u::File(dest, nullptr);
   sg_size_t written        = file->write(file_size);
   XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1", written, file_size,
   simgrid::s4u::File* file = new simgrid::s4u::File(dest, nullptr);
   sg_size_t written        = file->write(file_size);
   XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1", written, file_size,
-           simgrid::s4u::Actor::self()->getName().c_str());
+           simgrid::s4u::Actor::self()->getCname());
   delete file;
   return written;
 }
   delete file;
   return written;
 }
@@ -38,7 +38,7 @@ static sg_size_t read_local_file(const char* src)
   sg_size_t file_size      = file->size();
   sg_size_t read           = file->read(file_size);
 
   sg_size_t file_size      = file->size();
   sg_size_t read           = file->read(file_size);
 
-  XBT_INFO("%s has read %llu on %s", simgrid::s4u::Actor::self()->getName().c_str(), read, src);
+  XBT_INFO("%s has read %llu on %s", simgrid::s4u::Actor::self()->getCname(), read, src);
   delete file;
 
   return read;
   delete file;
 
   return read;
@@ -51,7 +51,7 @@ static void hsm_put(const char* remote_host, const char* src, const char* dest)
   sg_size_t read_size = read_local_file(src);
 
   // Send file
   sg_size_t read_size = read_local_file(src);
 
   // Send file
-  XBT_INFO("%s sends %llu to %s", simgrid::s4u::this_actor::getName().c_str(), read_size, remote_host);
+  XBT_INFO("%s sends %llu to %s", simgrid::s4u::this_actor::getCname(), read_size, remote_host);
   char* payload                    = bprintf("%s %llu", dest, read_size);
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(remote_host);
   mailbox->put(payload, static_cast<double>(read_size));
   char* payload                    = bprintf("%s %llu", dest, read_size);
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(remote_host);
   mailbox->put(payload, static_cast<double>(read_size));