Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename S4U::Channel to S4U::Mailbox. It was not a good idea
[simgrid.git] / src / s4u / s4u_mailbox.cpp
1 /* Copyright (c) 2006-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "../../include/simgrid/s4u/mailbox.hpp"
8 #include "xbt/log.h"
9 #include "msg/msg_private.h"
10 #include "msg/msg_mailbox.h"
11
12
13 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_channel,"S4U Communication Mailboxes");
14
15
16 using namespace simgrid;
17
18 boost::unordered_map <std::string, s4u::Mailbox *> *s4u::Mailbox::channels = new boost::unordered_map<std::string, s4u::Mailbox*> ();
19
20
21 s4u::Mailbox::Mailbox(const char*name, smx_rdv_t inferior) {
22         p_inferior = inferior;
23         channels->insert({name, this});
24 }
25 s4u::Mailbox *s4u::Mailbox::byName(const char*name) {
26         s4u::Mailbox * res;
27         try {
28                 res = channels->at(name);
29         } catch (std::out_of_range& e) {
30                 res = new Mailbox(name,simcall_rdv_create(name));
31         }
32         return res;
33 }