4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(comm);
11 message::message(message_type t, double a, double c)
12 : type(t), amount(a) , credit(c)
14 // compute message size
15 // arbitrary: 8 for type, and 8 for each double
18 size = opt::bookkeeping ? 24 : 16; // type + amount + (credit)?
21 size = 16 + opt::comm_cost(amount); // type + amount + data size
29 std::string message::to_string()
31 std::ostringstream oss;
34 oss << "CTRL: " << amount << " (info)";
36 oss << "; " << credit << " (credit)";
39 oss << "DATA: " << amount << " (load)";
48 oss << "UNKNOWN MESSAGE TYPE: " << type;
54 void message_queue::push(msg_task_t task)
56 if (queue.push(task)) {
57 // list was empty, the push must be signaled
64 bool message_queue::pop(message*& msg, msg_host_t& from, double timeout)
67 if (!queue.try_pop(task)) {
72 if (!queue.try_pop(task)) {
73 XBT_DEBUG("waiting for a message to come");
75 if (!cond.timedwait(mutex, timeout))
80 bool pop_was_successful = queue.try_pop(task);
81 xbt_assert(pop_was_successful);
85 msg = static_cast<message*>(MSG_task_get_data(task));
86 from = MSG_task_get_source(task);
87 MSG_task_destroy(task);
89 XBT_DEBUG("received %s from %s",
90 msg->to_string().c_str(), MSG_host_get_name(from));