11 enum message_type { INFO, CREDIT, LOAD, CTRL_CLOSE, DATA_CLOSE };
13 message(message_type t, double a): type(t), amount(a) { }
15 message_type get_type() const { return type; }
16 double get_amount() const { return amount; }
17 double get_size() const;
19 std::string to_string();
28 // Push a message on queue
29 void push(m_task_t task);
31 // Try to pop a message. Returns true on success.
32 // Parameter "timeout" may be 0 for non-blocking operation, -1 for
33 // infinite waiting, or any positive timeout.
34 bool pop(message*& msg, m_host_t& from, double timeout);
36 bool empty() const { return queue.empty(); }
37 size_t size() const { return queue.size(); }
42 std::queue<m_task_t> queue;