8 #include "sync_queue.h"
12 enum message_type { CTRL, DATA, CTRL_CLOSE, DATA_CLOSE };
14 message(message_type t, double a, double c = 0.0);
16 message_type get_type() const { return type; }
17 double get_amount() const { return amount; }
18 double get_credit() const { return credit; }
19 double get_size() const { return size; }
21 std::string to_string();
32 // Push a message on queue
33 void push(m_task_t task);
35 // Try to pop a message. Returns true on success.
36 // Parameter "timeout" may be 0 for non-blocking operation, -1 for
37 // infinite waiting, or any positive timeout.
38 bool pop(message*& msg, m_host_t& from, double timeout);
40 bool empty() const { return queue.empty(); }
41 size_t size() const { return queue.size(); }
46 sync_queue<m_task_t> queue;