WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
S4U_Mailbox.h
1 
11 #ifndef WRENCH_S4U_MAILBOX_H
12 #define WRENCH_S4U_MAILBOX_H
13 
14 
15 #include <string>
16 #include <map>
17 #include <set>
18 
19 #include <simgrid/s4u.hpp>
20 
21 namespace wrench {
22 
23  /***********************/
25  /***********************/
26 
27  class SimulationMessage;
28  class S4U_PendingCommunication;
29 
33  class S4U_Mailbox {
34 
35  public:
36  static std::unique_ptr<SimulationMessage> getMessage(simgrid::s4u::Mailbox *mailbox);
37  static std::unique_ptr<SimulationMessage> getMessage(simgrid::s4u::Mailbox *mailbox, double timeout);
38  static void putMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *m);
39  static void dputMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *msg);
40  static std::shared_ptr<S4U_PendingCommunication> iputMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *msg);
41  static std::shared_ptr<S4U_PendingCommunication> igetMessage(simgrid::s4u::Mailbox *mailbox);
42 
43  static unsigned long generateUniqueSequenceNumber();
44 
45  static simgrid::s4u::Mailbox *getTemporaryMailbox();
46  static void retireTemporaryMailbox(simgrid::s4u::Mailbox *mailbox);
47 
48  static void createMailboxPool(unsigned long num_mailboxes);
49 
50  static simgrid::s4u::Mailbox *generateUniqueMailbox(std::string prefix);
51 
52  static unsigned long mailbox_pool_size;
53 
54  private:
55  static std::deque<simgrid::s4u::Mailbox *> free_mailboxes;
56  static std::set<simgrid::s4u::Mailbox *> used_mailboxes;
57  static std::deque<simgrid::s4u::Mailbox *> mailboxes_to_drain;
58 
59 
60  };
61 
62  /***********************/
64  /***********************/
65 
66 };
67 
68 
69 #endif //WRENCH_S4U_MAILBOX_H
wrench::S4U_Mailbox::iputMessage
static std::shared_ptr< S4U_PendingCommunication > iputMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *msg)
Asynchronously send a message to a mailbox.
Definition: S4U_Mailbox.cpp:182
wrench::S4U_Mailbox
Wrappers around S4U's communication methods.
Definition: S4U_Mailbox.h:33
wrench::SimulationMessage
Top-level class to describe a message communicated by processes in the simulation.
Definition: SimulationMessage.h:28
wrench
Definition: Action.cpp:28
wrench::S4U_Mailbox::generateUniqueSequenceNumber
static unsigned long generateUniqueSequenceNumber()
Generate a unique sequence number.
Definition: S4U_Mailbox.cpp:244
wrench::S4U_Mailbox::putMessage
static void putMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *m)
Synchronously send a message to a mailbox.
Definition: S4U_Mailbox.cpp:120
wrench::S4U_Mailbox::getTemporaryMailbox
static simgrid::s4u::Mailbox * getTemporaryMailbox()
Get a temporary mailbox.
Definition: S4U_Mailbox.cpp:255
wrench::S4U_Mailbox::retireTemporaryMailbox
static void retireTemporaryMailbox(simgrid::s4u::Mailbox *mailbox)
Retire a temporary mailbox.
Definition: S4U_Mailbox.cpp:295
wrench::S4U_Mailbox::igetMessage
static std::shared_ptr< S4U_PendingCommunication > igetMessage(simgrid::s4u::Mailbox *mailbox)
Asynchronously receive a message from a mailbox.
Definition: S4U_Mailbox.cpp:217
wrench::S4U_Mailbox::dputMessage
static void dputMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *msg)
Asynchronously send a message to a mailbox in a "fire and forget" fashion.
Definition: S4U_Mailbox.cpp:147
wrench::S4U_Mailbox::createMailboxPool
static void createMailboxPool(unsigned long num_mailboxes)
Create the pool of mailboxes to use.
Definition: S4U_Mailbox.cpp:310
wrench::S4U_Mailbox::getMessage
static std::unique_ptr< SimulationMessage > getMessage(simgrid::s4u::Mailbox *mailbox)
Synchronously receive a message from a mailbox.
Definition: S4U_Mailbox.cpp:48
wrench::S4U_Mailbox::generateUniqueMailbox
static simgrid::s4u::Mailbox * generateUniqueMailbox(std::string prefix)
Generate a unique (non-temporary) mailbox.
Definition: S4U_Mailbox.cpp:321