1 // Asynchronous communicator
10 #include "msg_thread.h"
17 // Send a message to the "dest" mailbox
18 void send(const char* dest, message* msg);
20 // Try to flush pending sending communications.
21 // If "wait" is true, blocks until success.
22 void flush(bool wait);
24 // Try to get a message. Returns true on success.
25 // Parameter "timeout" may be 0 for non-blocking operation, -1 for
26 // infinite waiting, or any positive timeout.
27 bool recv(message*& msg, m_host_t& from, double timeout) {
28 return received.pop(msg, from, timeout);
35 // List of pending send communications
36 typedef std::vector<msg_comm_t> sent_comm_type;
37 sent_comm_type sent_comm;
39 // Queue of received messages
40 message_queue received;
42 // Handling of receiving thread
43 msg_thread* receiver_thread;
46 // Used to chek if a communication is successfull before destroying it
47 static void comm_check_n_destroy(msg_comm_t comm);
48 // If comm is over, call comm_check_n_destroy(comm), and return true
49 static bool comm_test_n_destroy(msg_comm_t comm);
52 #endif // !COMMUNICATOR_H