- 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(),
- std::tr1::bind(xbt_dynar_push,
- comms, std::tr1::placeholders::_1));
- MSG_comm_waitany(comms);
- xbt_dynar_reset(comms);
- flush_sent();
+ 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);