#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
-#include <boost/multi_index/composite_key.hpp>
+#include <boost/multi_index/global_fun.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <exceptions/exceptions.h>
class ExchangeStats {
public:
+ static uint32_t transid_hash(boost::shared_ptr<T> packet) {
+ return packet->getTransid() & 1023;
+ }
+
/// \brief List of packets (sent or received).
///
/// List of packets based on multi index container allows efficient
boost::multi_index::indexed_by<
boost::multi_index::sequenced<>,
boost::multi_index::hashed_non_unique<
- boost::multi_index::const_mem_fun<
- T, uint32_t, &T::getTransid
+ boost::multi_index::global_fun<
+ boost::shared_ptr<T>, uint32_t, &ExchangeStats::transid_hash
>
>
>
} else {
PktListTransidIndex& idx = sent_packets_.template get<1>();
std::pair<PktListTransidIterator,PktListTransidIterator> p =
- idx.equal_range(transid);
+ idx.equal_range(transid & 1023);
++unordered_lookups_;
unordered_lookup_size_sum_ += std::distance(p.first, p.second);
for (PktListTransidIterator it = p.first; it != p.second;
boost::scoped_ptr<StatsMgr4> stats_mgr(new StatsMgr4());
stats_mgr->addExchangeStats(StatsMgr4::XCHG_DO);
- uint32_t transid[packets_num] = { 64322, 100203, 1, 232324, 6786, 23, 4523, 777883, 98082, 3 };
+ uint32_t transid[packets_num] = { 1, 1024, 2, 1025, 3, 1026, 4, 1027, 5, 1028 };
for (int i = 0; i < packets_num; ++i) {
- // uint32_t transid = i & 0xFFFFFFFE | !(i & 1);
boost::shared_ptr<Pkt4> sent_packet(createPacket4(DHCPDISCOVER,
transid[i]));
ASSERT_NO_THROW(