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)
37 bool message_queue::pop(message*& msg, m_host_t& from, double timeout)
40 volatile double deadline =
41 timeout > 0 ? MSG_get_clock() + timeout : 0.0;
43 while (queue.empty() && (!deadline || deadline > MSG_get_clock())) {
45 XBT_DEBUG("waiting for a message to come");
48 cond.timedwait(mutex, deadline - MSG_get_clock());
53 if (e.category != timeout_error)
64 m_task_t task = queue.front();
66 msg = static_cast<message*>(MSG_task_get_data(task));
67 from = MSG_task_get_source(task);
68 MSG_task_destroy(task);
70 XBT_DEBUG("received %s from %s",
71 msg->to_string().c_str(), MSG_host_get_name(from));