Skip to content

Commit

Permalink
fixed is_reserved
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquintides committed Dec 26, 2023
1 parent 0a6da69 commit 8365ccb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions include/boost/unordered/detail/foa/concurrent_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1579,24 +1579,24 @@ class concurrent_table:
}
}

static bool is_reserved(group_type* pg,std::size_t pos)
static bool is_really_occupied(group_type* pg,std::size_t pos)
{
return is_reserved(
return is_really_occupied(
std::integral_constant<bool,group_type::regular_layout>{},pg,pos);
}

static bool is_reserved(
std::true_type, /* regular layout */
group_type* pg,std::size_t pos)
static bool is_really_occupied(
/* regular layout, almost-latch-free insertion -> spurious non-zeros */
std::true_type,group_type* pg,std::size_t pos)
{
return reinterpret_cast<std::atomic<unsigned char>*>(pg)[pos]==1;
return reinterpret_cast<std::atomic<unsigned char>*>(pg)[pos]>1;
}

static bool is_reserved(
std::false_type, /* non-regular layout, never reserved */
group_type*,std::size_t)
static bool is_really_occupied(
/* non-regular layout, latched insertion -> no false positives */
std::false_type,group_type*,std::size_t)
{
return false;
return true;
}

template<typename GroupAccessMode,typename F>
Expand Down Expand Up @@ -1636,7 +1636,7 @@ class concurrent_table:
auto mask=this->match_really_occupied(pg,last);
while(mask){
auto n=unchecked_countr_zero(mask);
if(BOOST_LIKELY(!is_reserved(pg,n))&&!f(pg,n,p+n))return false;
if(BOOST_LIKELY(is_really_occupied(pg,n))&&!f(pg,n,p+n))return false;
mask&=mask-1;
}
}
Expand Down Expand Up @@ -1671,7 +1671,7 @@ class concurrent_table:
auto mask=this->match_really_occupied(&g,last);
while(mask){
auto n=unchecked_countr_zero(mask);
if(BOOST_LIKELY(!is_reserved(&g,n)))f(&g,n,p+n);
if(BOOST_LIKELY(is_really_occupied(&g,n)))f(&g,n,p+n);
mask&=mask-1;
}
}
Expand All @@ -1693,7 +1693,7 @@ class concurrent_table:
auto mask=this->match_really_occupied(&g,last);
while(mask){
auto n=unchecked_countr_zero(mask);
if(BOOST_LIKELY(!is_reserved(&g,n))&&!f(p+n))return false;
if(BOOST_LIKELY(is_really_occupied(&g,n))&&!f(p+n))return false;
mask&=mask-1;
}
return true;
Expand Down

0 comments on commit 8365ccb

Please sign in to comment.