#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