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)
66 msg_task_t task = nullptr;
67 if (!queue.try_pop(task)) {
72 if (!queue.try_pop(task)) {
73 XBT_DEBUG("waiting for a message to come");
76 hit_timeout = !cond.timedwait(mutex, timeout);
81 bool pop_was_successful = queue.try_pop(task);
82 xbt_assert(hit_timeout || pop_was_successful);
89 msg = static_cast<message*>(MSG_task_get_data(task));
90 from = MSG_task_get_source(task);
91 MSG_task_destroy(task);
93 XBT_DEBUG("received %s from %s",
94 msg->to_string().c_str(), MSG_host_get_name(from));