forked from boostorg/unordered
strengthened erase, relaxed metadata ops
This commit is contained in:
@ -202,7 +202,7 @@ private:
|
|||||||
template<typename Integral>
|
template<typename Integral>
|
||||||
struct atomic_integral
|
struct atomic_integral
|
||||||
{
|
{
|
||||||
#if defined(BOOST_UNORDERED_LATCH_FREE)
|
#if 0&&defined(BOOST_UNORDERED_LATCH_FREE)
|
||||||
operator Integral()const{return n.load(std::memory_order_acquire);}
|
operator Integral()const{return n.load(std::memory_order_acquire);}
|
||||||
void operator=(Integral m){n.store(m,std::memory_order_release);}
|
void operator=(Integral m){n.store(m,std::memory_order_release);}
|
||||||
void operator|=(Integral m){n.fetch_or(m);}
|
void operator|=(Integral m){n.fetch_or(m);}
|
||||||
@ -553,7 +553,7 @@ public:
|
|||||||
#if defined(BOOST_UNORDERED_LATCH_FREE)
|
#if defined(BOOST_UNORDERED_LATCH_FREE)
|
||||||
~concurrent_table(){
|
~concurrent_table(){
|
||||||
std::cout
|
std::cout
|
||||||
<<"version: 2024/02/10 20:50; "
|
<<"version: 2024/02/12 12:00; "
|
||||||
<<"lf: "<<(double)size()/capacity()<<"; "
|
<<"lf: "<<(double)size()/capacity()<<"; "
|
||||||
<<"size: "<<size()<<", "
|
<<"size: "<<size()<<", "
|
||||||
<<"capacity: "<<capacity()<<"; "
|
<<"capacity: "<<capacity()<<"; "
|
||||||
@ -872,7 +872,7 @@ public:
|
|||||||
if(f(cast_for(group_shared{},type_policy::value_from(*p)))){
|
if(f(cast_for(group_shared{},type_policy::value_from(*p)))){
|
||||||
//pg->reset(n);
|
//pg->reset(n);
|
||||||
auto pc=reinterpret_cast<std::atomic<unsigned char>*>(pg)+n;
|
auto pc=reinterpret_cast<std::atomic<unsigned char>*>(pg)+n;
|
||||||
if(pc->exchange(0,std::memory_order_release)!=0){
|
if(pc->exchange(0)!=0){
|
||||||
auto& sc=local_size_ctrl();
|
auto& sc=local_size_ctrl();
|
||||||
sc.size.fetch_sub(1,std::memory_order_relaxed);
|
sc.size.fetch_sub(1,std::memory_order_relaxed);
|
||||||
sc.mcos.fetch_add(
|
sc.mcos.fetch_add(
|
||||||
@ -1274,8 +1274,9 @@ private:
|
|||||||
#if defined(BOOST_UNORDERED_LATCH_FREE)
|
#if defined(BOOST_UNORDERED_LATCH_FREE)
|
||||||
static bool is_occupied(group_type* pg,std::size_t pos)
|
static bool is_occupied(group_type* pg,std::size_t pos)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<std::atomic<unsigned char>*>(pg)[pos].
|
//return reinterpret_cast<std::atomic<unsigned char>*>(pg)[pos].
|
||||||
load(std::memory_order_acquire)>1;
|
// load(std::memory_order_acquire)>1;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static bool is_occupied(group_type* pg,std::size_t pos)
|
static bool is_occupied(group_type* pg,std::size_t pos)
|
||||||
@ -1297,14 +1298,14 @@ private:
|
|||||||
{
|
{
|
||||||
auto& acnt=access_counter(pos);
|
auto& acnt=access_counter(pos);
|
||||||
for(;;){
|
for(;;){
|
||||||
auto n=acnt.load(std::memory_order_acquire);
|
auto n=
|
||||||
if(n%2==1)continue;
|
acnt.load(std::memory_order_acquire)&
|
||||||
|
~boost::uint32_t(1);
|
||||||
|
|
||||||
auto res=f();
|
auto res=f();
|
||||||
|
|
||||||
std::atomic_thread_fence(std::memory_order_acquire);
|
std::atomic_thread_fence(std::memory_order_acquire);
|
||||||
if(acnt.load(std::memory_order_acquire)!=n)continue;
|
if(BOOST_LIKELY(acnt.load(std::memory_order_relaxed)==n))return {res,n};
|
||||||
else return {res,n};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1328,8 +1329,10 @@ private:
|
|||||||
{
|
{
|
||||||
auto &acnt=access_counter(pos);
|
auto &acnt=access_counter(pos);
|
||||||
for(;;){
|
for(;;){
|
||||||
auto n=acnt.load(std::memory_order_acquire);
|
auto n=
|
||||||
if(n%2==1)continue;
|
acnt.load(std::memory_order_acquire)&
|
||||||
|
~boost::uint32_t(1);
|
||||||
|
//if(n%2==1)continue;
|
||||||
|
|
||||||
if(save_access(pos,n,f))return;
|
if(save_access(pos,n,f))return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user