Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename S4U::Channel to S4U::Mailbox. It was not a good idea
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 12 Aug 2015 19:39:03 +0000 (21:39 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 12 Aug 2015 19:39:03 +0000 (21:39 +0200)
examples/s4u/dumb/s4u_test.cpp
include/simgrid/s4u.h
include/simgrid/s4u/mailbox.hpp [moved from include/simgrid/s4u/channel.hpp with 51% similarity]
include/simgrid/s4u/process.hpp
src/s4u/s4u_mailbox.cpp [moved from src/s4u/s4u_channel.cpp with 55% similarity]
src/s4u/s4u_process.cpp
tools/cmake/DefinePackages.cmake

index f85ac31..51001e3 100644 (file)
@@ -18,7 +18,7 @@ public:
        int main(int argc, char **argv) {
                XBT_INFO("Hello s4u, I'm ready to serve");
 
        int main(int argc, char **argv) {
                XBT_INFO("Hello s4u, I'm ready to serve");
 
-               char *msg = recvstr(*Channel::byName("worker"));
+               char *msg = recvstr(*Mailbox::byName("worker"));
                XBT_INFO("I received '%s'",msg);
                XBT_INFO("I'm done. See you.");
                return 1;
                XBT_INFO("I received '%s'",msg);
                XBT_INFO("I'm done. See you.");
                return 1;
@@ -32,7 +32,7 @@ public:
 
        int main(int argc, char **argv) {
                XBT_INFO("Hello s4u, I have something to send");
 
        int main(int argc, char **argv) {
                XBT_INFO("Hello s4u, I have something to send");
-               sendstr(*Channel::byName("worker"),"GaBuZoMeu");
+               sendstr(*Mailbox::byName("worker"),"GaBuZoMeu");
 
                XBT_INFO("I'm done. See you.");
                return 1;
 
                XBT_INFO("I'm done. See you.");
                return 1;
index 1814e33..6742142 100644 (file)
@@ -6,7 +6,7 @@
 #ifndef SIMGRID_S4U_S4U_H
 #define SIMGRID_S4U_S4U_H
 
 #ifndef SIMGRID_S4U_S4U_H
 #define SIMGRID_S4U_S4U_H
 
-#include "simgrid/s4u/channel.hpp"
+#include "s4u/mailbox.hpp"
 #include "simgrid/s4u/engine.hpp"
 #include "simgrid/s4u/host.hpp"
 #include "simgrid/s4u/process.hpp"
 #include "simgrid/s4u/engine.hpp"
 #include "simgrid/s4u/host.hpp"
 #include "simgrid/s4u/process.hpp"
similarity index 51%
rename from include/simgrid/s4u/channel.hpp
rename to include/simgrid/s4u/mailbox.hpp
index 1c3abd2..c76a4d9 100644 (file)
@@ -3,8 +3,8 @@
 /* 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. */
 
 /* 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. */
 
-#ifndef SIMGRID_S4U_CHANNEL_HPP
-#define SIMGRID_S4U_CHANNEL_HPP
+#ifndef SIMGRID_S4U_MAILBOX_HPP
+#define SIMGRID_S4U_MAILBOX_HPP
 
 #include <boost/unordered_map.hpp>
 
 
 #include <boost/unordered_map.hpp>
 
 namespace simgrid {
 namespace s4u {
 
 namespace simgrid {
 namespace s4u {
 
-/** @brief Channel
+/** @brief Mailboxes
  *
  * Rendez-vous point for network communications, similar to URLs on which you could post and retrieve data.
  *
  * Rendez-vous point for network communications, similar to URLs on which you could post and retrieve data.
- * They are not network locations (you can post and retrieve on a given mailbox from anywhere on the network).
+ * They are not network locations: you can post and retrieve on a given mailbox from anywhere on the network.
+ * You can access any mailbox without any latency. The network delay are only related to the location of the
+ * sender and receiver.
  */
  */
-class Channel {
+class Mailbox {
        friend Process;
 
 private:
        friend Process;
 
 private:
-       Channel(const char*name, smx_rdv_t inferior);
+       Mailbox(const char*name, smx_rdv_t inferior);
 public:
 public:
-       ~Channel();
+       ~Mailbox();
        
 protected:
        smx_rdv_t getInferior() { return p_inferior; }
 
 public:
        
 protected:
        smx_rdv_t getInferior() { return p_inferior; }
 
 public:
-       /** Retrieve the channel associated to the given string */
-       static Channel *byName(const char *name);
+       /** Retrieve the mailbox associated to the given string */
+       static Mailbox *byName(const char *name);
 
 private:
        std::string p_name;
        smx_rdv_t p_inferior;
 
 private:
        std::string p_name;
        smx_rdv_t p_inferior;
-       static boost::unordered_map<std::string, Channel *> *channels;
+       static boost::unordered_map<std::string, Mailbox *> *channels;
 };
 }} // namespace simgrid::s4u
 
 };
 }} // namespace simgrid::s4u
 
-#endif /* SIMGRID_S4U_CHANNEL_HPP */
+#endif /* SIMGRID_S4U_MAILBOX_HPP */
index db9f76c..b8a9fb1 100644 (file)
@@ -12,7 +12,7 @@ namespace simgrid {
 namespace s4u {
 
 class Host;
 namespace s4u {
 
 class Host;
-class Channel;
+class Mailbox;
 
 /** @brief Simulation Agent
  *
 
 /** @brief Simulation Agent
  *
@@ -85,10 +85,10 @@ public:
        //void* recv(const char *mailbox);
 
        /** Block the process until it gets a string message (to be freed after use) from the given mailbox */
        //void* recv(const char *mailbox);
 
        /** Block the process until it gets a string message (to be freed after use) from the given mailbox */
-       char *recvstr(Channel &chan);
+       char *recvstr(Mailbox &chan);
 
        /** Block the process until it delivers a string message (that will be copied) to the given mailbox */
 
        /** Block the process until it delivers a string message (that will be copied) to the given mailbox */
-       void sendstr(Channel &chan, const char*msg);
+       void sendstr(Mailbox &chan, const char*msg);
 
 protected:
        smx_process_t getInferior() {return p_smx_process;}
 
 protected:
        smx_process_t getInferior() {return p_smx_process;}
similarity index 55%
rename from src/s4u/s4u_channel.cpp
rename to src/s4u/s4u_mailbox.cpp
index 396b887..2ef1c0d 100644 (file)
@@ -4,30 +4,30 @@
 /* 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. */
 
 /* 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. */
 
+#include "../../include/simgrid/s4u/mailbox.hpp"
 #include "xbt/log.h"
 #include "msg/msg_private.h"
 #include "msg/msg_mailbox.h"
 
 #include "xbt/log.h"
 #include "msg/msg_private.h"
 #include "msg/msg_mailbox.h"
 
-#include "simgrid/s4u/channel.hpp"
 
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_channel,"S4U Communication Channels");
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_channel,"S4U Communication Mailboxes");
 
 
 using namespace simgrid;
 
 
 
 using namespace simgrid;
 
-boost::unordered_map <std::string, s4u::Channel *> *s4u::Channel::channels = new boost::unordered_map<std::string, s4u::Channel*> ();
+boost::unordered_map <std::string, s4u::Mailbox *> *s4u::Mailbox::channels = new boost::unordered_map<std::string, s4u::Mailbox*> ();
 
 
 
 
-s4u::Channel::Channel(const char*name, smx_rdv_t inferior) {
+s4u::Mailbox::Mailbox(const char*name, smx_rdv_t inferior) {
        p_inferior = inferior;
        channels->insert({name, this});
 }
        p_inferior = inferior;
        channels->insert({name, this});
 }
-s4u::Channel *s4u::Channel::byName(const char*name) {
-       s4u::Channel * res;
+s4u::Mailbox *s4u::Mailbox::byName(const char*name) {
+       s4u::Mailbox * res;
        try {
                res = channels->at(name);
        } catch (std::out_of_range& e) {
        try {
                res = channels->at(name);
        } catch (std::out_of_range& e) {
-               res = new Channel(name,simcall_rdv_create(name));
+               res = new Mailbox(name,simcall_rdv_create(name));
        }
        return res;
 }
        }
        return res;
 }
index bb86178..b75cd58 100644 (file)
@@ -4,13 +4,13 @@
 /* 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. */
 
 /* 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. */
 
+#include "../../include/simgrid/s4u/mailbox.hpp"
 #include "xbt/log.h"
 #include "msg/msg_private.h"
 #include "msg/msg_mailbox.h"
 
 #include "simgrid/s4u/host.hpp"
 #include "simgrid/s4u/process.hpp"
 #include "xbt/log.h"
 #include "msg/msg_private.h"
 #include "msg/msg_mailbox.h"
 
 #include "simgrid/s4u/host.hpp"
 #include "simgrid/s4u/process.hpp"
-#include "simgrid/s4u/channel.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_process,"S4U processes");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_process,"S4U processes");
 
@@ -81,7 +81,7 @@ void s4u::Process::execute(double flops) {
        simcall_process_execute(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
 }
 
        simcall_process_execute(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
 }
 
-char *s4u::Process::recvstr(Channel &chan) {
+char *s4u::Process::recvstr(Mailbox &chan) {
        char *res=NULL;
        size_t res_size=sizeof(res);
 
        char *res=NULL;
        size_t res_size=sizeof(res);
 
@@ -89,7 +89,7 @@ char *s4u::Process::recvstr(Channel &chan) {
 
     return res;
 }
 
     return res;
 }
-void s4u::Process::sendstr(Channel &chan, const char*msg) {
+void s4u::Process::sendstr(Mailbox &chan, const char*msg) {
        char *msg_cpy=xbt_strdup(msg);
        smx_synchro_t comm = simcall_comm_isend(p_smx_process, chan.getInferior(), strlen(msg),
                        -1/*rate*/, msg_cpy, sizeof(void *),
        char *msg_cpy=xbt_strdup(msg);
        smx_synchro_t comm = simcall_comm_isend(p_smx_process, chan.getInferior(), strlen(msg),
                        -1/*rate*/, msg_cpy, sizeof(void *),
index 2930684..f563ee1 100644 (file)
@@ -379,9 +379,9 @@ else()
 endif()
 
 set(S4U_SRC
 endif()
 
 set(S4U_SRC
-  src/s4u/s4u_channel.cpp
   src/s4u/s4u_engine.cpp  
   src/s4u/s4u_host.cpp  
   src/s4u/s4u_engine.cpp  
   src/s4u/s4u_host.cpp  
+  src/s4u/s4u_mailbox.cpp
   src/s4u/s4u_process.cpp
 )
 
   src/s4u/s4u_process.cpp
 )
 
@@ -690,9 +690,9 @@ set(headers_to_install
   include/simgrid/simix.h
   include/simgrid/host.h
   include/simgrid/link.h
   include/simgrid/simix.h
   include/simgrid/host.h
   include/simgrid/link.h
-  include/simgrid/s4u/channel.hpp  
   include/simgrid/s4u/engine.hpp  
   include/simgrid/s4u/host.hpp  
   include/simgrid/s4u/engine.hpp  
   include/simgrid/s4u/host.hpp  
+  include/simgrid/s4u/mailbox.hpp  
   include/simgrid/s4u/process.hpp
   include/simgrid/s4u.h
   include/smpi/mpi.h
   include/simgrid/s4u/process.hpp
   include/simgrid/s4u.h
   include/smpi/mpi.h