mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 10:57:16 +02:00
Clean up concurrent_table's merge impl
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
#include <atomic>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/mp11/tuple.hpp>
|
||||
@ -692,11 +693,14 @@ public:
|
||||
using merge_table_type=concurrent_table<TypePolicy,Hash2,Pred2,Allocator>;
|
||||
using super2=typename merge_table_type::super;
|
||||
|
||||
// for clang
|
||||
boost::ignore_unused<super2>();
|
||||
|
||||
auto lck=exclusive_access(*this,x);
|
||||
size_type s=unprotected_size();
|
||||
static_cast<super2&>(x).for_all_elements( /* super::for_all_elements -> unprotected */
|
||||
x.super2::for_all_elements( /* super2::for_all_elements -> unprotected */
|
||||
[&,this](group_type* pg,unsigned int n,element_type* p){
|
||||
erase_on_exit<merge_table_type> e{x,pg,n,p};
|
||||
typename merge_table_type::erase_on_exit e{x,pg,n,p};
|
||||
if(!unprotected_emplace(type_policy::move(*p)))e.rollback();
|
||||
});
|
||||
return size_type{unprotected_size()-s};
|
||||
@ -852,29 +856,21 @@ private:
|
||||
>::type
|
||||
cast_for(group_exclusive,value_type& x){return x;}
|
||||
|
||||
template<typename Table>
|
||||
struct erase_on_exit
|
||||
{
|
||||
using table_group_type=typename Table::group_type;
|
||||
using table_element_type=typename Table::element_type;
|
||||
using table_super_type=typename Table::super;
|
||||
|
||||
erase_on_exit(
|
||||
Table& x_,table_group_type* pg_,unsigned int pos_,table_element_type* p_):
|
||||
concurrent_table& x_,
|
||||
group_type* pg_,unsigned int pos_,element_type* p_):
|
||||
x{x_},pg{pg_},pos{pos_},p{p_}{}
|
||||
~erase_on_exit()
|
||||
{
|
||||
if(!rollback_)
|
||||
static_cast<table_super_type&>(x).erase(pg,pos,p);
|
||||
}
|
||||
~erase_on_exit(){if(!rollback_)x.super::erase(pg,pos,p);}
|
||||
|
||||
void rollback(){rollback_=true;}
|
||||
|
||||
Table &x;
|
||||
table_group_type *pg;
|
||||
unsigned int pos;
|
||||
table_element_type *p;
|
||||
bool rollback_=false;
|
||||
concurrent_table &x;
|
||||
group_type *pg;
|
||||
unsigned int pos;
|
||||
element_type *p;
|
||||
bool rollback_=false;
|
||||
};
|
||||
|
||||
template<typename GroupAccessMode,typename Key,typename F>
|
||||
|
Reference in New Issue
Block a user