]> AND Private Git Repository - loba.git/blob - communicator.h
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
f1ee1d96cc0eb11d98ad1cb95585f8f6c417448c
[loba.git] / communicator.h
1 // Asynchronous communicator
2
3 #ifndef COMMUNICATOR_H
4 #define COMMUNICATOR_H
5
6 #include <list>
7
8 #include <msg/msg.h>
9 #include <xbt/sysdep.h>
10 #include "neighbor.h"
11
12 class communicator {
13 public:
14     communicator();
15     ~communicator();
16
17     void send_info(const neighbor& dest, double amount);
18     void send_credit(const neighbor& dest, double amount);
19     void send_load(const neighbor& dest, double amount);
20
21     bool recv_info(double& amount, m_host_t& from);
22     bool recv_credit(double& amount, m_host_t& from);
23     bool recv_load(double& amount, m_host_t& from);
24
25     int send_backlog();
26
27 private:
28     enum message_type { INFO_MSG, CREDIT_MSG };
29     class message;
30
31     // List of pending send communications
32     std::list<msg_comm_t> sent_comm;
33
34     // Control channel for receiving
35     char*       ctrl_mbox;
36     msg_comm_t  ctrl_comm;
37     m_task_t    ctrl_task;
38
39     // Data channel for receiving
40     char*       data_mbox;
41     msg_comm_t  data_comm;
42     m_task_t    data_task;
43
44     bool recv_ctrl(message_type type, double& amount, m_host_t& from);
45     void send(const char* dest, m_task_t task);
46     void flush_sent();
47 };
48
49 #endif // !COMMUNICATOR_H
50
51 // Local variables:
52 // mode: c++
53 // End: