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

Private GIT Repository
Wip++...
[loba.git] / communicator.h
index ca0d3b2031c5b092078a82a75b4f682167fc46a7..f1ee1d96cc0eb11d98ad1cb95585f8f6c417448c 100644 (file)
@@ -4,27 +4,46 @@
 #define COMMUNICATOR_H
 
 #include <list>
-#include <string>
+
 #include <msg/msg.h>
+#include <xbt/sysdep.h>
+#include "neighbor.h"
 
 class communicator {
 public:
     communicator();
     ~communicator();
 
-    void send(m_task_t task, const char *dest);
-    void send(m_task_t task, const std::string& dest);
-    m_task_t recv();
-    int sent_count();
+    void send_info(const neighbor& dest, double amount);
+    void send_credit(const neighbor& dest, double amount);
+    void send_load(const neighbor& dest, double amount);
+
+    bool recv_info(double& amount, m_host_t& from);
+    bool recv_credit(double& amount, m_host_t& from);
+    bool recv_load(double& amount, m_host_t& from);
+
+    int send_backlog();
 
 private:
-    typedef std::list<msg_comm_t> comm_list;
-    comm_list   sent_comm;
-    char*       recv_mbox;
-    msg_comm_t  recv_comm;
-    m_task_t    recv_task;
+    enum message_type { INFO_MSG, CREDIT_MSG };
+    class message;
+
+    // List of pending send communications
+    std::list<msg_comm_t> sent_comm;
+
+    // Control channel for receiving
+    char*       ctrl_mbox;
+    msg_comm_t  ctrl_comm;
+    m_task_t    ctrl_task;
+
+    // Data channel for receiving
+    char*       data_mbox;
+    msg_comm_t  data_comm;
+    m_task_t    data_task;
 
-    void send_acknowledge();
+    bool recv_ctrl(message_type type, double& amount, m_host_t& from);
+    void send(const char* dest, m_task_t task);
+    void flush_sent();
 };
 
 #endif // !COMMUNICATOR_H