1 // Asynchronous communicator
12 enum message_type { INFO, CREDIT, LOAD, CTRL_CLOSE, DATA_CLOSE };
14 message(message_type t, double a): type(t), amount(a) { }
16 message_type get_type() const { return type; }
17 double get_amount() const { return amount; }
19 std::string to_string();
33 void send(const char* dest, message* msg);
34 bool recv(message*& msg, m_host_t& from, bool wait);
35 void flush(bool wait);
37 void next_close_on_ctrl_is_last();
38 void next_close_on_data_is_last();
41 // List of pending send communications
42 std::list<msg_comm_t> sent_comm;
44 // Control channel for receiving
45 std::string ctrl_mbox;
48 bool ctrl_close_is_last;
50 // Data channel for receiving
51 std::string data_mbox;
54 bool data_close_is_last;
56 const char* get_ctrl_mbox() const { return ctrl_mbox.c_str(); }
57 const char* get_data_mbox() const { return data_mbox.c_str(); }
59 static void comm_push_in_dynar(xbt_dynar_t dynar, msg_comm_t comm);
60 static bool comm_test_n_destroy(msg_comm_t comm);
63 #endif // !COMMUNICATOR_H