1 // Asynchronous communicator
13 enum message_type { INFO, CREDIT, LOAD, CTRL_CLOSE, DATA_CLOSE };
15 message(message_type t, double a): type(t), amount(a) { }
17 message_type get_type() const { return type; }
18 double get_amount() const { return amount; }
20 std::string to_string();
34 void send(const char* dest, message* msg);
35 bool recv(message*& msg, m_host_t& from, bool wait);
36 void flush(bool wait);
38 void next_close_on_ctrl_is_last();
39 void next_close_on_data_is_last();
45 // List of pending send communications
46 std::list<msg_comm_t> sent_comm;
47 static const int send_count_before_flush;
50 // Control channel for receiving
53 bool ctrl_close_is_last;
55 // Data channel for receiving
58 bool data_close_is_last;
60 const char* get_ctrl_mbox() const { return host->get_ctrl_mbox(); }
61 const char* get_data_mbox() const { return host->get_data_mbox(); }
63 static bool comm_test_n_destroy(msg_comm_t comm);
66 #endif // !COMMUNICATOR_H