-m_task_t communicator::recv()
-{
- m_task_t task = NULL;
- if (comm_test_n_destroy(recv_comm)) {
- task = recv_task;
- recv_task = NULL;
- recv_comm = MSG_task_irecv(&recv_task, recv_mbox);
+bool communicator::recv_load(double& amount, m_host_t& from)
+{
+ bool res = comm_test_n_destroy(data_comm);
+ if (res) {
+ amount = MSG_task_get_data_size(data_task);
+ from = MSG_task_get_source(data_task);
+ MSG_task_destroy(data_task);
+ data_task = NULL;
+ data_comm = MSG_task_irecv(&data_task, data_mbox);
+ }
+ return res;
+}
+
+bool communicator::recv_ctrl(message_type type, double& amount, m_host_t& from)
+{
+ bool res = MSG_comm_test(ctrl_comm);
+ if (res) {
+ message* msg = (message* )MSG_task_get_data(ctrl_task);
+ if (msg->type == type) {
+ MSG_comm_destroy(ctrl_comm);
+ amount = msg->amount;
+ from = MSG_task_get_source(ctrl_task);
+ delete msg;
+ MSG_task_destroy(ctrl_task);
+ ctrl_task = NULL;
+ ctrl_comm = MSG_task_irecv(&ctrl_task, ctrl_mbox);
+ } else {
+ res = false;
+ }