diff --git a/include/boost/unordered/detail/foa/concurrent_table.hpp b/include/boost/unordered/detail/foa/concurrent_table.hpp index 57a309d3..cae13539 100644 --- a/include/boost/unordered/detail/foa/concurrent_table.hpp +++ b/include/boost/unordered/detail/foa/concurrent_table.hpp @@ -514,6 +514,8 @@ public: x.arrays=ah.release(); x.size_ctrl.ml=x.initial_max_load(); x.size_ctrl.size=0; + BOOST_UNORDERED_SWAP_STATS( + this->get_cumulative_stats(),x.get_cumulative_stats()); } concurrent_table(compatible_nonconcurrent_table&& x): diff --git a/include/boost/unordered/detail/foa/table.hpp b/include/boost/unordered/detail/foa/table.hpp index 2f02a7a4..cf96e622 100644 --- a/include/boost/unordered/detail/foa/table.hpp +++ b/include/boost/unordered/detail/foa/table.hpp @@ -1,6 +1,6 @@ /* Fast open-addressing hash table. * - * Copyright 2022-2023 Joaquin M Lopez Munoz. + * Copyright 2022-2024 Joaquin M Lopez Munoz. * Copyright 2023 Christian Mazakas. * Copyright 2024 Braden Ganetsky. * Distributed under the Boost Software License, Version 1.0. @@ -593,6 +593,8 @@ private: x.arrays=ah.release(); x.size_ctrl.ml=x.initial_max_load(); x.size_ctrl.size=0; + BOOST_UNORDERED_SWAP_STATS( + this->get_cumulative_stats(),x.get_cumulative_stats()); } template diff --git a/test/unordered/stats_tests.cpp b/test/unordered/stats_tests.cpp index 2d0f9cfe..64492edf 100644 --- a/test/unordered/stats_tests.cpp +++ b/test/unordered/stats_tests.cpp @@ -7,6 +7,8 @@ #ifdef BOOST_UNORDERED_CFOA_TESTS #include #include +#include +#include #include "../cfoa/helpers.hpp" #else #include "../helpers/unordered.hpp" @@ -302,10 +304,26 @@ template void test_stats() 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().unsuccessful_lookup, stats_empty); - - // TODO: concurrent<->unordered interop } +#if defined(BOOST_UNORDERED_CFOA_TESTS) +template +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_) { #if defined(BOOST_UNORDERED_CFOA_TESTS) test_stats< @@ -315,6 +333,12 @@ UNORDERED_AUTO_TEST (stats_) { test_stats< boost::concurrent_flat_set< int, boost::hash, std::equal_to, unequal_allocator>>(); + test_stats_concurrent_unordered_interop< + boost::unordered_flat_map, + boost::concurrent_flat_map>(); + test_stats_concurrent_unordered_interop< + boost::unordered_flat_set, + boost::concurrent_flat_set>(); #elif defined(BOOST_UNORDERED_FOA_TESTS) test_stats< boost::unordered_flat_map<