]> AND Private Git Repository - loba.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Use a vector for sent_comm (smaller and faster than a list).
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 9 Feb 2011 14:14:05 +0000 (15:14 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 9 Feb 2011 14:14:29 +0000 (15:14 +0100)
communicator.cpp
communicator.h

index daf14348393761cded88e166bbdfd4d313e4622e..ce0e79f15ccaa75a8f1ecfe5932e3ac69adfd241 100644 (file)
@@ -60,7 +60,10 @@ void communicator::send(const char* dest, message* msg)
 
 void communicator::flush(bool wait)
 {
 
 void communicator::flush(bool wait)
 {
-    sent_comm.remove_if(comm_test_n_destroy);
+    sent_comm_type::iterator bound;
+    bound = std::remove_if(sent_comm.begin(), sent_comm.end(),
+                           comm_test_n_destroy);
+    sent_comm.erase(bound, sent_comm.end());
     if (wait && !sent_comm.empty()) {
         msg_comm_t comms[sent_comm.size()];
         std::copy(sent_comm.begin(), sent_comm.end(), comms);
     if (wait && !sent_comm.empty()) {
         msg_comm_t comms[sent_comm.size()];
         std::copy(sent_comm.begin(), sent_comm.end(), comms);
index cfe8624e62493f37425c5ed4c440e15a63896b58..ce74f077f5b86e33af81d6a91e96d181d34fa558 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef COMMUNICATOR_H
 #define COMMUNICATOR_H
 
 #ifndef COMMUNICATOR_H
 #define COMMUNICATOR_H
 
-#include <list>
+#include <vector>
 #include <msg/msg.h>
 #include "hostdata.h"
 #include "messages.h"
 #include <msg/msg.h>
 #include "hostdata.h"
 #include "messages.h"
@@ -31,7 +31,8 @@ private:
     const hostdata* host;
 
     // List of pending send communications
     const hostdata* host;
 
     // List of pending send communications
-    std::list<msg_comm_t> sent_comm;
+    typedef std::vector<msg_comm_t> sent_comm_type;
+    sent_comm_type sent_comm;
 
     // Queue of received messages
     message_queue received;
 
     // Queue of received messages
     message_queue received;