implemented proper stats handling on concurrent<->unordered move construction

This commit is contained in:
joaquintides
2024-05-03 18:04:21 +02:00
parent 37451ecc94
commit 223f64752d
3 changed files with 31 additions and 3 deletions

View File

@ -514,6 +514,8 @@ public:
x.arrays=ah.release(); x.arrays=ah.release();
x.size_ctrl.ml=x.initial_max_load(); x.size_ctrl.ml=x.initial_max_load();
x.size_ctrl.size=0; x.size_ctrl.size=0;
BOOST_UNORDERED_SWAP_STATS(
this->get_cumulative_stats(),x.get_cumulative_stats());
} }
concurrent_table(compatible_nonconcurrent_table&& x): concurrent_table(compatible_nonconcurrent_table&& x):

View File

@ -1,6 +1,6 @@
/* Fast open-addressing hash table. /* Fast open-addressing hash table.
* *
* Copyright 2022-2023 Joaquin M Lopez Munoz. * Copyright 2022-2024 Joaquin M Lopez Munoz.
* Copyright 2023 Christian Mazakas. * Copyright 2023 Christian Mazakas.
* Copyright 2024 Braden Ganetsky. * Copyright 2024 Braden Ganetsky.
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
@ -593,6 +593,8 @@ private:
x.arrays=ah.release(); x.arrays=ah.release();
x.size_ctrl.ml=x.initial_max_load(); x.size_ctrl.ml=x.initial_max_load();
x.size_ctrl.size=0; x.size_ctrl.size=0;
BOOST_UNORDERED_SWAP_STATS(
this->get_cumulative_stats(),x.get_cumulative_stats());
} }
template<typename ExclusiveLockGuard> template<typename ExclusiveLockGuard>

View File

@ -7,6 +7,8 @@
#ifdef BOOST_UNORDERED_CFOA_TESTS #ifdef BOOST_UNORDERED_CFOA_TESTS
#include <boost/unordered/concurrent_flat_map.hpp> #include <boost/unordered/concurrent_flat_map.hpp>
#include <boost/unordered/concurrent_flat_set.hpp> #include <boost/unordered/concurrent_flat_set.hpp>
#include <boost/unordered/unordered_flat_map.hpp>
#include <boost/unordered/unordered_flat_set.hpp>
#include "../cfoa/helpers.hpp" #include "../cfoa/helpers.hpp"
#else #else
#include "../helpers/unordered.hpp" #include "../helpers/unordered.hpp"
@ -302,10 +304,26 @@ template <class Container> void test_stats()
check_insertion_stats(c7.get_stats().insertion, stats_full); check_insertion_stats(c7.get_stats().insertion, stats_full);
check_lookup_stats(c7.get_stats().successful_lookup, stats_empty); check_lookup_stats(c7.get_stats().successful_lookup, stats_empty);
check_lookup_stats(c7.get_stats().unsuccessful_lookup, stats_empty); check_lookup_stats(c7.get_stats().unsuccessful_lookup, stats_empty);
// TODO: concurrent<->unordered interop
} }
#if defined(BOOST_UNORDERED_CFOA_TESTS)
template <class Container, class ConcurrentContainer>
void test_stats_concurrent_unordered_interop()
{
ConcurrentContainer cc1;
insert_n(cc1,5000);
insert_n(cc1,5000); // produces successful lookups
auto s=cc1.get_stats();
Container c1(std::move(cc1));
check_container_stats(cc1.get_stats(),stats_empty);
check_container_stats(c1.get_stats(),s);
ConcurrentContainer cc2(std::move(c1));
check_container_stats(c1.get_stats(),stats_empty);
check_container_stats(cc2.get_stats(),s);
}
#endif
UNORDERED_AUTO_TEST (stats_) { UNORDERED_AUTO_TEST (stats_) {
#if defined(BOOST_UNORDERED_CFOA_TESTS) #if defined(BOOST_UNORDERED_CFOA_TESTS)
test_stats< test_stats<
@ -315,6 +333,12 @@ UNORDERED_AUTO_TEST (stats_) {
test_stats< test_stats<
boost::concurrent_flat_set< boost::concurrent_flat_set<
int, boost::hash<int>, std::equal_to<int>, unequal_allocator<int>>>(); int, boost::hash<int>, std::equal_to<int>, unequal_allocator<int>>>();
test_stats_concurrent_unordered_interop<
boost::unordered_flat_map<int, int>,
boost::concurrent_flat_map<int, int>>();
test_stats_concurrent_unordered_interop<
boost::unordered_flat_set<int>,
boost::concurrent_flat_set<int>>();
#elif defined(BOOST_UNORDERED_FOA_TESTS) #elif defined(BOOST_UNORDERED_FOA_TESTS)
test_stats< test_stats<
boost::unordered_flat_map< boost::unordered_flat_map<