Commit b6f23aa6 authored by Etienne Renault's avatar Etienne Renault
Browse files

bricks: update

* bricks/brick-hashset: here.
parent 71ef91a6
......@@ -43,7 +43,8 @@ using hash::hash128_t;
struct DefaultHasher
{
auto hash( int64_t v ) const -> std::pair<int64_t, int64_t>
// auto hash( int64_t v ) const -> std::pair<int64_t, int64_t>
auto hash( int64_t v ) const
{
return std::make_pair( v, ~v );
}
......@@ -85,7 +86,7 @@ struct FastCell : CellBase< T, Hasher >
hash64_t _hash;
template< typename Value >
bool is( Value v, hash64_t hash, Hasher &h ) {
bool is( const Value &v, hash64_t hash, Hasher &h ) {
return _hash == hash && h.equal( _value, v );
}
......@@ -106,7 +107,7 @@ struct CompactCell : CellBase< T, Hasher >
T _value;
template< typename Value >
bool is( Value v, hash64_t, Hasher &h ) {
bool is( const Value &v, hash64_t, Hasher &h ) {
return h.equal( _value, v );
}
......@@ -165,7 +166,7 @@ struct FastAtomicCell : CellBase< T, Hasher >
}
template< typename Value >
bool is( Value v, hash64_t hash, Hasher &h ) {
bool is( const Value &v, hash64_t hash, Hasher &h ) {
hash |= 0x1;
if ( ( (hash << 2) | 1) != (_hashlock | 1) )
return false;
......@@ -248,7 +249,7 @@ struct AtomicCell : CellBase< T, Hasher >
}
template< typename Value >
bool is( Value v, hash64_t hash, Hasher &h ) {
bool is( const Value &v, hash64_t hash, Hasher &h ) {
return value.load().tag() == ( highbits( hash, Tagged< T >::tag_bits ) | 1 ) &&
h.equal( value.load().t, v );
}
......@@ -606,7 +607,7 @@ struct _ConcurrentHashSet : HashSetBase< Cell >
}
template< typename T >
iterator find( T x ) {
iterator find( const T &x ) {
return findHinted( x, hasher.hash( x ).first );
}
......@@ -641,7 +642,7 @@ struct _ConcurrentHashSet : HashSetBase< Cell >
}
template< typename T >
iterator findHinted( T x, hash64_t h ) {
iterator findHinted( const T &x, hash64_t h ) {
while ( true ) {
Find fr = findCell( x, h, _l.currentRow );
switch ( fr.r ) {
......@@ -661,7 +662,7 @@ struct _ConcurrentHashSet : HashSetBase< Cell >
}
template< typename T >
Find findCell( T v, hash64_t h, unsigned rowIndex )
Find findCell( const T &v, hash64_t h, unsigned rowIndex )
{
if ( changed( rowIndex ) )
return Find( Resolution::Growing );
......@@ -848,13 +849,20 @@ struct _ConcurrentHashSet : HashSetBase< Cell >
} while( true );
}
void increaseUsage() {
if ( ++_l.inserts == syncPoint ) {
_s->used.fetch_add( syncPoint, std::memory_order_relaxed );
_l.inserts = 0;
}
void increaseUsage()
{
if ( ++_l.inserts == syncPoint )
updateUsage();
}
void updateUsage()
{
_s->used.fetch_add( _l.inserts, std::memory_order_relaxed );
_l.inserts = 0;
}
~_ConcurrentHashSet() { updateUsage(); }
explicit _ConcurrentHashSet( Hasher h = Hasher(), unsigned maxGrows = 64 )
: Base( h ), _s( new Shared( maxGrows ) )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment