X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/147d0e88c4da14c801d15e0875bedb474180bea2..6f5ec5fdc42f96a8fe95f4b846b163d4dc92e0c8:/communicator.h diff --git a/communicator.h b/communicator.h index ca0d3b2..f1ee1d9 100644 --- a/communicator.h +++ b/communicator.h @@ -4,27 +4,46 @@ #define COMMUNICATOR_H #include -#include + #include +#include +#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 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 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