Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Port RawContext to C++
[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 <xbt/base.h>
12 #include <simgrid/s4u/actor.hpp>
13
14 namespace simgrid {
15 namespace s4u {
16
17 class Comm;
18
19 /** @brief Mailboxes
20  *
21  * Rendez-vous point for network communications, similar to URLs on which you could post and retrieve data.
22  * They are not network locations: you can post and retrieve on a given mailbox from anywhere on the network.
23  * You can access any mailbox without any latency. The network delay are only related to the location of the
24  * sender and receiver.
25  */
26 XBT_PUBLIC_CLASS Mailbox {
27         friend Comm;
28
29 private:
30         Mailbox(const char*name, smx_rdv_t inferior);
31 public:
32         ~Mailbox();
33         
34 protected:
35         smx_rdv_t getInferior() { return p_inferior; }
36
37 public:
38         /** Get the name of that mailbox */
39         const char *getName();
40         /** Retrieve the mailbox associated to the given string */
41         static Mailbox *byName(const char *name);
42
43 private:
44         std::string p_name;
45         smx_rdv_t p_inferior;
46         static boost::unordered_map<std::string, Mailbox *> *mailboxes;
47 };
48 }} // namespace simgrid::s4u
49
50 #endif /* SIMGRID_S4U_MAILBOX_HPP */