- 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);
+ using namespace std::tr1;
+ using namespace std::tr1::placeholders;
+
+ sent_comm.remove_if(comm_test_n_destroy);
+ if (wait && !sent_comm.empty()) {
+ xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
+ while (!sent_comm.empty()) {
+ std::for_each(sent_comm.begin(), sent_comm.end(),
+ bind(xbt_dynar_push,
+ comms, bind(misc::address<msg_comm_t>(), _1)));
+ MSG_comm_waitany(comms);
+ xbt_dynar_reset(comms);
+ sent_comm.remove_if(comm_test_n_destroy);
+ }
+ xbt_dynar_free(&comms);