Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c76a4d9ec241e821de43901dea2036cae5f8ab65
[simgrid.git] / include / simgrid / s4u / mailbox.hpp
1 /* Copyright (c) 2006-2015. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_S4U_MAILBOX_HPP
7 #define SIMGRID_S4U_MAILBOX_HPP
8
9 #include <boost/unordered_map.hpp>
10
11 #include "simgrid/s4u/process.hpp"
12
13 namespace simgrid {
14 namespace s4u {
15
16 /** @brief Mailboxes
17  *
18  * Rendez-vous point for network communications, similar to URLs on which you could post and retrieve data.
19  * They are not network locations: you can post and retrieve on a given mailbox from anywhere on the network.
20  * You can access any mailbox without any latency. The network delay are only related to the location of the
21  * sender and receiver.
22  */
23 class Mailbox {
24         friend Process;
25
26 private:
27         Mailbox(const char*name, smx_rdv_t inferior);
28 public:
29         ~Mailbox();
30         
31 protected:
32         smx_rdv_t getInferior() { return p_inferior; }
33
34 public:
35         /** Retrieve the mailbox associated to the given string */
36         static Mailbox *byName(const char *name);
37
38 private:
39         std::string p_name;
40         smx_rdv_t p_inferior;
41         static boost::unordered_map<std::string, Mailbox *> *channels;
42 };
43 }} // namespace simgrid::s4u
44
45 #endif /* SIMGRID_S4U_MAILBOX_HPP */