8 #include "sync_queue.h"
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; }
18 double get_size() const;
20 std::string to_string();
29 // Push a message on queue
30 void push(m_task_t task);
32 // Try to pop a message. Returns true on success.
33 // Parameter "timeout" may be 0 for non-blocking operation, -1 for
34 // infinite waiting, or any positive timeout.
35 bool pop(message*& msg, m_host_t& from, double timeout);
37 bool empty() const { return queue.empty(); }
38 size_t size() const { return queue.size(); }
43 sync_queue<m_task_t> queue;