4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(comm);
11 std::string message::to_string()
13 static const char* str[] = { "INFO", "CREDIT", "LOAD",
14 "CTRL_CLOSE", "DATA_CLOSE" };
15 std::ostringstream oss;
16 oss << str[type] << ": " << amount;
20 double message::get_size() const
22 // arbitrary: 8 for type, and 8 for amount
25 size += opt::comm_cost(amount);
29 void message_queue::push(m_task_t task)
31 if (queue.push(task)) {
32 // list was empty, the push must be signaled
39 bool message_queue::pop(message*& msg, m_host_t& from, double timeout)
42 if (!queue.try_pop(task)) {
47 if (!queue.try_pop(task)) {
49 XBT_DEBUG("waiting for a message to come");
52 cond.timedwait(mutex, timeout);
60 if (e.category != timeout_error)
63 return false; // got a timeout
65 bool pop_was_successful = queue.try_pop(task);
66 xbt_assert(pop_was_successful);
71 msg = static_cast<message*>(MSG_task_get_data(task));
72 from = MSG_task_get_source(task);
73 MSG_task_destroy(task);
75 XBT_DEBUG("received %s from %s",
76 msg->to_string().c_str(), MSG_host_get_name(from));