diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-08-27 16:17:21 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-08-27 16:17:21 -0700 |
commit | b11ffc9635204f11daac4f20596dc4e3da687eee (patch) | |
tree | 18ff0abd97c5b267e868104c3f0736e0e577b1ba /node/Multicaster.hpp | |
parent | 3947807b1ffc844f62eeec7dd0fe552d280fe807 (diff) | |
download | infinitytier-b11ffc9635204f11daac4f20596dc4e3da687eee.tar.gz infinitytier-b11ffc9635204f11daac4f20596dc4e3da687eee.zip |
Integrate Hashtable into Multicaster, where @mwarning found heaviest std::map() overhead.
Diffstat (limited to 'node/Multicaster.hpp')
-rw-r--r-- | node/Multicaster.hpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp index 0dd199f9..898c4db7 100644 --- a/node/Multicaster.hpp +++ b/node/Multicaster.hpp @@ -36,6 +36,7 @@ #include <list> #include "Constants.hpp" +#include "Hashtable.hpp" #include "Address.hpp" #include "MAC.hpp" #include "MulticastGroup.hpp" @@ -56,6 +57,18 @@ class Packet; class Multicaster : NonCopyable { private: + struct Key + { + Key() : nwid(0),mg() {} + Key(uint64_t n,const MulticastGroup &g) : nwid(n),mg(g) {} + + uint64_t nwid; + MulticastGroup mg; + + inline bool operator==(const Key &k) const throw() { return ((nwid == k.nwid)&&(mg == k.mg)); } + inline unsigned long hashCode() const throw() { return (mg.hashCode() ^ (unsigned long)(nwid ^ (nwid >> 32))); } + }; + struct MulticastGroupMember { MulticastGroupMember() {} @@ -89,7 +102,7 @@ public: inline void add(uint64_t now,uint64_t nwid,const MulticastGroup &mg,const Address &member) { Mutex::Lock _l(_groups_m); - _add(now,nwid,mg,_groups[std::pair<uint64_t,MulticastGroup>(nwid,mg)],member); + _add(now,nwid,mg,_groups[Multicaster::Key(nwid,mg)],member); } /** @@ -181,7 +194,7 @@ private: void _add(uint64_t now,uint64_t nwid,const MulticastGroup &mg,MulticastGroupStatus &gs,const Address &member); const RuntimeEnvironment *RR; - std::map< std::pair<uint64_t,MulticastGroup>,MulticastGroupStatus > _groups; + Hashtable<Multicaster::Key,MulticastGroupStatus> _groups; Mutex _groups_m; }; |