diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-06-18 15:42:12 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-06-18 15:42:12 -0700 |
commit | be4f08a548556bd6e7f22bc48035d11aa319fae8 (patch) | |
tree | 097a7ac8f52316040f789dd7f12c39b1b0c642ca /node | |
parent | 6fc150bddb871ef0b6f3ba6a84a7faf01d8a57a3 (diff) | |
parent | 0073d0f694f925d925db96d25e2a504abda99722 (diff) | |
download | infinitytier-be4f08a548556bd6e7f22bc48035d11aa319fae8.tar.gz infinitytier-be4f08a548556bd6e7f22bc48035d11aa319fae8.zip |
Merge pull request #186 from mwarning/txQueue_vector
replace txQueue list by vector for faster memory access and less allo…
Diffstat (limited to 'node')
-rw-r--r-- | node/Multicaster.cpp | 20 | ||||
-rw-r--r-- | node/Multicaster.hpp | 2 |
2 files changed, 13 insertions, 9 deletions
diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp index 0cc4fb87..360233fe 100644 --- a/node/Multicaster.cpp +++ b/node/Multicaster.cpp @@ -320,10 +320,12 @@ void Multicaster::clean(uint64_t now) { Mutex::Lock _l(_groups_m); for(std::map< std::pair<uint64_t,MulticastGroup>,MulticastGroupStatus >::iterator mm(_groups.begin());mm!=_groups.end();) { - for(std::list<OutboundMulticast>::iterator tx(mm->second.txQueue.begin());tx!=mm->second.txQueue.end();) { - if ((tx->expired(now))||(tx->atLimit())) - mm->second.txQueue.erase(tx++); - else ++tx; + for(std::vector<OutboundMulticast>::iterator tx(mm->second.txQueue.begin());tx!=mm->second.txQueue.end();) { + if ((tx->expired(now))||(tx->atLimit())) { + // erase element (replace by last) + *tx = mm->second.txQueue.back(); + mm->second.txQueue.pop_back(); + } else ++tx; } unsigned long count = 0; @@ -371,14 +373,16 @@ void Multicaster::_add(uint64_t now,uint64_t nwid,const MulticastGroup &mg,Multi //TRACE("..MC %s joined multicast group %.16llx/%s via %s",member.toString().c_str(),nwid,mg.toString().c_str(),((learnedFrom) ? learnedFrom.toString().c_str() : "(direct)")); - for(std::list<OutboundMulticast>::iterator tx(gs.txQueue.begin());tx!=gs.txQueue.end();) { + for(std::vector<OutboundMulticast>::iterator tx(gs.txQueue.begin());tx!=gs.txQueue.end();) { if (tx->atLimit()) { gs.txQueue.erase(tx++); } else { tx->sendIfNew(RR,member); - if (tx->atLimit()) - gs.txQueue.erase(tx++); - else ++tx; + if (tx->atLimit()) { + // erase element (replace by last) + *tx = gs.txQueue.back(); + gs.txQueue.pop_back(); + } else ++tx; } } } diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp index c6c93b1f..281222b8 100644 --- a/node/Multicaster.hpp +++ b/node/Multicaster.hpp @@ -70,7 +70,7 @@ private: MulticastGroupStatus() : lastExplicitGather(0) {} uint64_t lastExplicitGather; - std::list<OutboundMulticast> txQueue; // pending outbound multicasts + std::vector<OutboundMulticast> txQueue; // pending outbound multicasts std::vector<MulticastGroupMember> members; // members of this group }; |