From: khizmax Date: Fri, 13 Nov 2015 20:10:30 +0000 (+0300) Subject: Fixed doc typo, reformatting X-Git-Tag: v2.1.0~68 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=364713fa3a507065fbf38839612538a3cde74050;p=libcds.git Fixed doc typo, reformatting --- diff --git a/cds/container/feldman_hashmap_rcu.h b/cds/container/feldman_hashmap_rcu.h index 7ad23b84..ebbd50e5 100644 --- a/cds/container/feldman_hashmap_rcu.h +++ b/cds/container/feldman_hashmap_rcu.h @@ -451,7 +451,7 @@ namespace cds { namespace container { /// Delete \p key from the map /** \p key_type must be constructible from value of type \p K. - The function deeltes the element with hash value equal to hash( key_type( key )) + The function deletes the element with hash value equal to hash( key_type( key )) Return \p true if \p key is found and deleted, \p false otherwise. diff --git a/cds/container/impl/feldman_hashmap.h b/cds/container/impl/feldman_hashmap.h index 2f8a03af..e9244454 100644 --- a/cds/container/impl/feldman_hashmap.h +++ b/cds/container/impl/feldman_hashmap.h @@ -475,7 +475,7 @@ namespace cds { namespace container { /// Delete \p key from the map /** \p key_type must be constructible from value of type \p K. - The function deeltes the element with hash value equal to hash( key_type( key )) + The function deletes the element with hash value equal to hash( key_type( key )) Return \p true if \p key is found and deleted, \p false otherwise. */ diff --git a/cds/container/split_list_map.h b/cds/container/split_list_map.h index 760b9b5b..8dbe5a13 100644 --- a/cds/container/split_list_map.h +++ b/cds/container/split_list_map.h @@ -237,7 +237,7 @@ namespace cds { namespace container { bool insert( K const& key ) { //TODO: pass arguments by reference (make_pair makes copy) - return base_class::insert( std::make_pair( key, mapped_type() ) ); + return base_class::insert( std::make_pair( key, mapped_type())); } /// Inserts new node @@ -255,7 +255,7 @@ namespace cds { namespace container { bool insert( K const& key, V const& val ) { //TODO: pass arguments by reference (make_pair makes copy) - return base_class::insert( std::make_pair(key, val) ); + return base_class::insert( std::make_pair(key, val)); } /// Inserts new node and initialize it by a functor @@ -293,7 +293,7 @@ namespace cds { namespace container { bool insert_with( K const& key, Func func ) { //TODO: pass arguments by reference (make_pair makes copy) - return base_class::insert( std::make_pair( key, mapped_type() ), func ); + return base_class::insert( std::make_pair( key, mapped_type()), func ); } /// For key \p key inserts data of type \p mapped_type created from \p args @@ -338,7 +338,7 @@ namespace cds { namespace container { std::pair update( K const& key, Func func, bool bAllowInsert = true ) { //TODO: pass arguments by reference (make_pair makes copy) - return base_class::update( std::make_pair( key, mapped_type() ), + return base_class::update( std::make_pair( key, mapped_type()), [&func](bool bNew, value_type& item, value_type const& /*val*/) { func( bNew, item ); }, @@ -375,7 +375,7 @@ namespace cds { namespace container { bool erase_with( K const& key, Less pred ) { CDS_UNUSED( pred ); - return base_class::erase_with( key, cds::details::predicate_wrapper() ); + return base_class::erase_with( key, cds::details::predicate_wrapper()); } /// Deletes \p key from the map @@ -461,7 +461,7 @@ namespace cds { namespace container { { CDS_UNUSED( pred ); guarded_ptr gp; - base_class::extract_with_( gp.guard(), key, cds::details::predicate_wrapper() ); + base_class::extract_with_( gp.guard(), key, cds::details::predicate_wrapper()); return gp; } @@ -539,7 +539,7 @@ namespace cds { namespace container { bool contains( K const& key, Less pred ) { CDS_UNUSED( pred ); - return base_class::contains( key, cds::details::predicate_wrapper() ); + return base_class::contains( key, cds::details::predicate_wrapper()); } //@cond template @@ -598,7 +598,7 @@ namespace cds { namespace container { { CDS_UNUSED( pred ); guarded_ptr gp; - base_class::get_with_( gp.guard(), key, cds::details::predicate_wrapper() ); + base_class::get_with_( gp.guard(), key, cds::details::predicate_wrapper()); return gp; } diff --git a/cds/container/split_list_set.h b/cds/container/split_list_set.h index 7b358b02..616f0f2c 100644 --- a/cds/container/split_list_set.h +++ b/cds/container/split_list_set.h @@ -208,7 +208,7 @@ namespace cds { namespace container { assert( pNode != nullptr ); scoped_node_ptr p(pNode); - if ( base_class::insert( *pNode ) ) { + if ( base_class::insert( *pNode )) { p.release(); return true; } @@ -335,7 +335,7 @@ namespace cds { namespace container { */ iterator begin() { - return iterator( base_class::begin() ); + return iterator( base_class::begin()); } /// Returns an iterator that addresses the location succeeding the last element in a set @@ -346,7 +346,7 @@ namespace cds { namespace container { */ iterator end() { - return iterator( base_class::end() ); + return iterator( base_class::end()); } /// Returns a forward const iterator addressing the first element in a set @@ -357,7 +357,7 @@ namespace cds { namespace container { /// Returns a forward const iterator addressing the first element in a set const_iterator cbegin() const { - return const_iterator( base_class::cbegin() ); + return const_iterator( base_class::cbegin()); } /// Returns an const iterator that addresses the location succeeding the last element in a set @@ -368,7 +368,7 @@ namespace cds { namespace container { /// Returns an const iterator that addresses the location succeeding the last element in a set const_iterator cend() const { - return const_iterator( base_class::cend() ); + return const_iterator( base_class::cend()); } public: @@ -386,7 +386,7 @@ namespace cds { namespace container { template bool insert( Q const& val ) { - return insert_node( alloc_node( val ) ); + return insert_node( alloc_node( val )); } /// Inserts new node @@ -506,7 +506,7 @@ namespace cds { namespace container { bool erase_with( Q const& key, Less pred ) { CDS_UNUSED( pred ); - return base_class::erase_with( key, typename maker::template predicate_wrapper::type() ); + return base_class::erase_with( key, typename maker::template predicate_wrapper::type()); } /// Deletes \p key from the set @@ -692,7 +692,7 @@ namespace cds { namespace container { bool contains( Q const& key, Less pred ) { CDS_UNUSED( pred ); - return base_class::contains( key, typename maker::template predicate_wrapper::type() ); + return base_class::contains( key, typename maker::template predicate_wrapper::type()); } //@cond template @@ -791,14 +791,14 @@ namespace cds { namespace container { bool extract_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less pred ) { CDS_UNUSED( pred ); - return base_class::extract_with_( guard, key, typename maker::template predicate_wrapper::type() ); + return base_class::extract_with_( guard, key, typename maker::template predicate_wrapper::type()); } template bool get_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less pred ) { CDS_UNUSED( pred ); - return base_class::get_with_( guard, key, typename maker::template predicate_wrapper::type() ); + return base_class::get_with_( guard, key, typename maker::template predicate_wrapper::type()); } //@endcond diff --git a/cds/intrusive/feldman_hashset_rcu.h b/cds/intrusive/feldman_hashset_rcu.h index f177b533..ab6782a5 100644 --- a/cds/intrusive/feldman_hashset_rcu.h +++ b/cds/intrusive/feldman_hashset_rcu.h @@ -59,7 +59,10 @@ namespace cds { namespace intrusive { > class FeldmanHashSet< cds::urcu::gc< RCU >, T, Traits >: protected feldman_hashset::multilevel_array { + //@cond typedef feldman_hashset::multilevel_array base_class; + //@endcond + public: typedef cds::urcu::gc< RCU > gc; ///< RCU garbage collector typedef T value_type; ///< type of value stored in the set @@ -431,7 +434,7 @@ namespace cds { namespace intrusive { */ void clear() { - clear_array( head(), head_size() ); + clear_array( head(), head_size()); } /// Checks if the set is empty @@ -1018,7 +1021,7 @@ namespace cds { namespace intrusive { rcu_lock rcuLock; if ( pos.pArr->nodes[pos.nSlot].load(memory_model::memory_order_acquire) == slot) { - if ( slot.ptr() ) { + if ( slot.ptr()) { if ( cmp( hash, hash_accessor()(*slot.ptr())) == 0 ) { // the item with that hash value already exists // Replace it with val @@ -1097,10 +1100,10 @@ namespace cds { namespace intrusive { assert( slot.bits() == 0 ); if ( pos.pArr->nodes[pos.nSlot].load( memory_model::memory_order_acquire ) == slot ) { - if ( slot.ptr() ) { - if ( cmp( hash, hash_accessor()(*slot.ptr()) ) == 0 && pred( *slot.ptr() ) ) { + if ( slot.ptr()) { + if ( cmp( hash, hash_accessor()(*slot.ptr())) == 0 && pred( *slot.ptr())) { // item found - replace it with nullptr - if ( pos.pArr->nodes[pos.nSlot].compare_exchange_strong( slot, node_ptr( nullptr ), memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) { + if ( pos.pArr->nodes[pos.nSlot].compare_exchange_strong( slot, node_ptr( nullptr ), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { --m_ItemCounter; stats().onEraseSuccess(); @@ -1125,7 +1128,7 @@ namespace cds { namespace intrusive { value_type * search(hash_type const& hash ) { - assert( gc::is_locked() ); + assert( gc::is_locked()); traverse_data pos( hash, *this ); hash_comparator cmp; @@ -1137,7 +1140,7 @@ namespace cds { namespace intrusive { // slot value has been changed - retry stats().onSlotChanged(); } - else if ( slot.ptr() && cmp( hash, hash_accessor()(*slot.ptr()) ) == 0 ) { + else if ( slot.ptr() && cmp( hash, hash_accessor()(*slot.ptr())) == 0 ) { // item found stats().onFindSuccess(); return slot.ptr(); diff --git a/cds/intrusive/impl/feldman_hashset.h b/cds/intrusive/impl/feldman_hashset.h index d2834f90..933d7b1e 100644 --- a/cds/intrusive/impl/feldman_hashset.h +++ b/cds/intrusive/impl/feldman_hashset.h @@ -92,7 +92,9 @@ namespace cds { namespace intrusive { > class FeldmanHashSet: protected feldman_hashset::multilevel_array { + //@cond typedef feldman_hashset::multilevel_array base_class; + //@endcond public: typedef GC gc; ///< Garbage collector @@ -229,7 +231,7 @@ namespace cds { namespace intrusive { if ( slot.bits() == base_class::flag_array_node ) { // array node, go down the tree assert( slot.ptr() != nullptr ); - pNode = to_array( slot.ptr() ); + pNode = to_array( slot.ptr()); idx = 0; nodeSize = arrayNodeSize; } @@ -258,7 +260,7 @@ namespace cds { namespace intrusive { } else { // end() - assert( pNode == m_set->head() ); + assert( pNode == m_set->head()); assert( idx == headSize ); m_pNode = pNode; m_idx = idx; @@ -287,7 +289,7 @@ namespace cds { namespace intrusive { if ( slot.bits() == base_class::flag_array_node ) { // array node, go down the tree assert( slot.ptr() != nullptr ); - pNode = to_array( slot.ptr() ); + pNode = to_array( slot.ptr()); nodeSize = arrayNodeSize; idx = nodeSize - 1; } @@ -316,7 +318,7 @@ namespace cds { namespace intrusive { } else { // rend() - assert( pNode == m_set->head() ); + assert( pNode == m_set->head()); assert( idx == endIdx ); m_pNode = pNode; m_idx = idx; @@ -342,7 +344,7 @@ namespace cds { namespace intrusive { template Iterator init_rbegin() const { - return Iterator( *this, head(), head_size() ); + return Iterator( *this, head(), head_size()); } template @@ -846,7 +848,7 @@ namespace cds { namespace intrusive { */ void clear() { - clear_array( head(), head_size() ); + clear_array( head(), head_size()); } /// Checks if the set is empty @@ -964,19 +966,19 @@ namespace cds { namespace intrusive { /// Returns a reverse iterator to the first element of the reversed set reverse_iterator rbegin() { - return reverse_iterator( *this, head(), head_size() ); + return reverse_iterator( *this, head(), head_size()); } /// Returns a const reverse iterator to the first element of the reversed set const_reverse_iterator rbegin() const { - return const_reverse_iterator( *this, head(), head_size() ); + return const_reverse_iterator( *this, head(), head_size()); } /// Returns a const reverse iterator to the first element of the reversed set const_reverse_iterator crbegin() { - return const_reverse_iterator( *this, head(), head_size() ); + return const_reverse_iterator( *this, head(), head_size()); } /// Returns a reverse iterator to the element following the last element of the reversed set @@ -1022,7 +1024,7 @@ namespace cds { namespace intrusive { if ( slot.bits() == base_class::flag_array_node ) { // array node, go down the tree assert( slot.ptr() != nullptr ); - clear_array( to_array( slot.ptr()), array_node_size() ); + clear_array( to_array( slot.ptr()), array_node_size()); break; } else if ( slot.bits() == base_class::flag_array_converting ) { @@ -1035,14 +1037,14 @@ namespace cds { namespace intrusive { assert( slot.ptr() != nullptr ); assert( slot.bits() == base_class::flag_array_node ); - clear_array( to_array( slot.ptr()), array_node_size() ); + clear_array( to_array( slot.ptr()), array_node_size()); break; } else { // data node if ( pArr->compare_exchange_strong( slot, node_ptr(), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { - if ( slot.ptr() ) { - gc::template retire( slot.ptr() ); + if ( slot.ptr()) { + gc::template retire( slot.ptr()); --m_ItemCounter; stats().onEraseSuccess(); } @@ -1125,15 +1127,15 @@ namespace cds { namespace intrusive { return false; if ( iter.m_pNode == head() && iter.m_idx >= head_size()) return false; - if ( iter.m_idx >= array_node_size() ) + if ( iter.m_idx >= array_node_size()) return false; for (;;) { node_ptr slot = iter.m_pNode->nodes[iter.m_idx].load( memory_model::memory_order_acquire ); - if ( slot.bits() == 0 && slot.ptr() == iter.pointer() ) { - if ( iter.m_pNode->nodes[iter.m_idx].compare_exchange_strong(slot, node_ptr(nullptr), memory_model::memory_order_acquire, atomics::memory_order_relaxed) ) { + if ( slot.bits() == 0 && slot.ptr() == iter.pointer()) { + if ( iter.m_pNode->nodes[iter.m_idx].compare_exchange_strong(slot, node_ptr(nullptr), memory_model::memory_order_acquire, atomics::memory_order_relaxed)) { // the item is guarded by iterator, so we may retire it safely - gc::template retire( slot.ptr() ); + gc::template retire( slot.ptr()); --m_ItemCounter; stats().onEraseSuccess(); return true; diff --git a/cds/intrusive/impl/michael_list.h b/cds/intrusive/impl/michael_list.h index c9b01576..c22bcac0 100644 --- a/cds/intrusive/impl/michael_list.h +++ b/cds/intrusive/impl/michael_list.h @@ -223,7 +223,7 @@ namespace cds { namespace intrusive { struct clean_disposer { void operator()( value_type * p ) { - michael_list::node_cleaner()( node_traits::to_node_ptr( p ) ); + michael_list::node_cleaner()( node_traits::to_node_ptr( p )); disposer()( p ); } }; @@ -234,7 +234,7 @@ namespace cds { namespace intrusive { static void retire_node( node_type * pNode ) { assert( pNode != nullptr ); - gc::template retire( node_traits::to_value_ptr( *pNode ) ); + gc::template retire( node_traits::to_value_ptr( *pNode )); } static bool link_node( node_type * pNode, position& pos ) @@ -286,12 +286,11 @@ namespace cds { namespace intrusive { marked_node_ptr pNext; do { pNext = pCur->m_pNext.load(memory_model::memory_order_relaxed); - g.assign( node_traits::to_value_ptr( pNext.ptr() )); - } while ( pNext != pCur->m_pNext.load(memory_model::memory_order_acquire) ); + g.assign( node_traits::to_value_ptr( pNext.ptr())); + } while ( pNext != pCur->m_pNext.load(memory_model::memory_order_acquire)); - if ( pNext.ptr() ) { - m_pNode = m_Guard.assign( g.template get() ); - } + if ( pNext.ptr()) + m_pNode = m_Guard.assign( g.template get()); else { m_pNode = nullptr; m_Guard.clear(); @@ -303,14 +302,14 @@ namespace cds { namespace intrusive { { for (;;) { marked_node_ptr p = pNode.load(memory_model::memory_order_relaxed); - if ( p.ptr() ) { - m_pNode = m_Guard.assign( node_traits::to_value_ptr( p.ptr() ) ); + if ( p.ptr()) { + m_pNode = m_Guard.assign( node_traits::to_value_ptr( p.ptr())); } else { m_pNode = nullptr; m_Guard.clear(); } - if ( p == pNode.load(memory_model::memory_order_acquire) ) + if ( p == pNode.load(memory_model::memory_order_acquire)) break; } } @@ -593,7 +592,7 @@ namespace cds { namespace intrusive { template bool erase( Q const& key ) { - return erase_at( m_pHead, key, key_comparator() ); + return erase_at( m_pHead, key, key_comparator()); } /// Deletes the item from the list using \p pred predicate for searching @@ -673,7 +672,7 @@ namespace cds { namespace intrusive { guarded_ptr extract( Q const& key ) { guarded_ptr gp; - extract_at( m_pHead, gp.guard(), key, key_comparator() ); + extract_at( m_pHead, gp.guard(), key, key_comparator()); return gp; } @@ -691,7 +690,7 @@ namespace cds { namespace intrusive { { CDS_UNUSED( pred ); guarded_ptr gp; - extract_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less() ); + extract_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less()); return gp; } @@ -759,7 +758,7 @@ namespace cds { namespace intrusive { template bool contains( Q const& key ) { - return find_at( m_pHead, key, key_comparator() ); + return find_at( m_pHead, key, key_comparator()); } //@cond template @@ -780,7 +779,7 @@ namespace cds { namespace intrusive { bool contains( Q const& key, Less pred ) { CDS_UNUSED( pred ); - return find_at( m_pHead, key, cds::opt::details::make_comparator_from_less() ); + return find_at( m_pHead, key, cds::opt::details::make_comparator_from_less()); } //@cond template @@ -824,7 +823,7 @@ namespace cds { namespace intrusive { guarded_ptr get( Q const& key ) { guarded_ptr gp; - get_at( m_pHead, gp.guard(), key, key_comparator() ); + get_at( m_pHead, gp.guard(), key, key_comparator()); return gp; } @@ -842,7 +841,7 @@ namespace cds { namespace intrusive { { CDS_UNUSED( pred ); guarded_ptr gp; - get_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less() ); + get_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less()); return gp; } @@ -856,12 +855,12 @@ namespace cds { namespace intrusive { marked_node_ptr head; while ( true ) { head = m_pHead.load(memory_model::memory_order_relaxed); - if ( head.ptr() ) - guard.assign( node_traits::to_value_ptr( *head.ptr() )); + if ( head.ptr()) + guard.assign( node_traits::to_value_ptr( *head.ptr())); if ( m_pHead.load(memory_model::memory_order_acquire) == head ) { if ( head.ptr() == nullptr ) break; - value_type& val = *node_traits::to_value_ptr( *head.ptr() ); + value_type& val = *node_traits::to_value_ptr( *head.ptr()); unlink( val ); } } @@ -902,7 +901,7 @@ namespace cds { namespace intrusive { // Hack: convert node_type to value_type. // In principle, auxiliary node can be non-reducible to value_type // We assume that comparator can correctly distinguish aux and regular node. - return insert_at( refHead, *node_traits::to_value_ptr( pNode ) ); + return insert_at( refHead, *node_traits::to_value_ptr( pNode )); } bool insert_at( atomic_node_ptr& refHead, value_type& val ) @@ -912,10 +911,10 @@ namespace cds { namespace intrusive { position pos; while ( true ) { - if ( search( refHead, val, pos, key_comparator() ) ) + if ( search( refHead, val, pos, key_comparator())) return false; - if ( link_node( pNode, pos ) ) { + if ( link_node( pNode, pos )) { ++m_ItemCounter; return true; } @@ -933,12 +932,12 @@ namespace cds { namespace intrusive { position pos; while ( true ) { - if ( search( refHead, val, pos, key_comparator() ) ) + if ( search( refHead, val, pos, key_comparator())) return false; typename gc::Guard guard; guard.assign( &val ); - if ( link_node( pNode, pos ) ) { + if ( link_node( pNode, pos )) { f( val ); ++m_ItemCounter; return true; @@ -956,12 +955,12 @@ namespace cds { namespace intrusive { node_type * pNode = node_traits::to_node_ptr( val ); while ( true ) { - if ( search( refHead, val, pos, key_comparator() ) ) { - if ( pos.pCur->m_pNext.load(memory_model::memory_order_acquire).bits() ) { + if ( search( refHead, val, pos, key_comparator())) { + if ( pos.pCur->m_pNext.load(memory_model::memory_order_acquire).bits()) { back_off()(); - continue ; // the node found is marked as deleted + continue; // the node found is marked as deleted } - assert( key_comparator()( val, *node_traits::to_value_ptr( *pos.pCur ) ) == 0 ); + assert( key_comparator()( val, *node_traits::to_value_ptr( *pos.pCur )) == 0 ); func( false, *node_traits::to_value_ptr( *pos.pCur ) , val ); return std::make_pair( true, false ); @@ -972,7 +971,7 @@ namespace cds { namespace intrusive { typename gc::Guard guard; guard.assign( &val ); - if ( link_node( pNode, pos ) ) { + if ( link_node( pNode, pos )) { ++m_ItemCounter; func( true, val, val ); return std::make_pair( true, true ); @@ -988,9 +987,9 @@ namespace cds { namespace intrusive { position pos; back_off bkoff; - while ( search( refHead, val, pos, key_comparator() ) ) { + while ( search( refHead, val, pos, key_comparator())) { if ( node_traits::to_value_ptr( *pos.pCur ) == &val ) { - if ( unlink_node( pos ) ) { + if ( unlink_node( pos )) { --m_ItemCounter; return true; } @@ -1008,8 +1007,8 @@ namespace cds { namespace intrusive { { back_off bkoff; while ( search( refHead, val, pos, cmp )) { - if ( unlink_node( pos ) ) { - f( *node_traits::to_value_ptr( *pos.pCur ) ); + if ( unlink_node( pos )) { + f( *node_traits::to_value_ptr( *pos.pCur )); --m_ItemCounter; return true; } @@ -1039,8 +1038,8 @@ namespace cds { namespace intrusive { position pos; back_off bkoff; while ( search( refHead, val, pos, cmp )) { - if ( unlink_node( pos ) ) { - dest.set( pos.guards.template get( position::guard_current_item ) ); + if ( unlink_node( pos )) { + dest.set( pos.guards.template get( position::guard_current_item )); --m_ItemCounter; return true; } @@ -1100,7 +1099,7 @@ namespace cds { namespace intrusive { pCur = pos.guards.protect( position::guard_current_item, *pPrev, [](marked_node_ptr p) -> value_type * { - return node_traits::to_value_ptr( p.ptr() ); + return node_traits::to_value_ptr( p.ptr()); }); while ( true ) { @@ -1114,9 +1113,9 @@ namespace cds { namespace intrusive { pNext = pos.guards.protect( position::guard_next_item, pCur->m_pNext, [](marked_node_ptr p ) -> value_type * { - return node_traits::to_value_ptr( p.ptr() ); + return node_traits::to_value_ptr( p.ptr()); }); - if ( pPrev->load(memory_model::memory_order_acquire).all() != pCur.ptr() ) { + if ( pPrev->load(memory_model::memory_order_acquire).all() != pCur.ptr()) { bkoff(); goto try_again; } @@ -1125,8 +1124,8 @@ namespace cds { namespace intrusive { if ( pNext.bits() == 1 ) { // pCur marked i.e. logically deleted. Help the erase/unlink function to unlink pCur node marked_node_ptr cur( pCur.ptr()); - if ( pPrev->compare_exchange_strong( cur, marked_node_ptr( pNext.ptr() ), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { - retire_node( pCur.ptr() ); + if ( pPrev->compare_exchange_strong( cur, marked_node_ptr( pNext.ptr()), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { + retire_node( pCur.ptr()); } else { bkoff(); @@ -1135,7 +1134,7 @@ namespace cds { namespace intrusive { } else { assert( pCur.ptr() != nullptr ); - int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr() ), val ); + int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr()), val ); if ( nCmp >= 0 ) { pos.pPrev = pPrev; pos.pCur = pCur.ptr(); diff --git a/cds/intrusive/split_list.h b/cds/intrusive/split_list.h index 8f3853d8..1afbf2bf 100644 --- a/cds/intrusive/split_list.h +++ b/cds/intrusive/split_list.h @@ -381,7 +381,7 @@ namespace cds { namespace intrusive { static size_t parent_bucket( size_t nBucket ) { assert( nBucket > 0 ); - return nBucket & ~( 1 << bitop::MSBnz( nBucket ) ); + return nBucket & ~( 1 << bitop::MSBnz( nBucket )); } dummy_node_type * init_bucket( size_t nBucket ) @@ -399,8 +399,8 @@ namespace cds { namespace intrusive { // Allocate a dummy node for new bucket { - dummy_node_type * pBucket = alloc_dummy_node( split_list::dummy_hash( nBucket ) ); - if ( m_List.insert_aux_node( pParentBucket, pBucket ) ) { + dummy_node_type * pBucket = alloc_dummy_node( split_list::dummy_hash( nBucket )); + if ( m_List.insert_aux_node( pParentBucket, pBucket )) { m_Buckets.bucket( nBucket, pBucket ); m_Stat.onNewBucket(); return pBucket; @@ -432,7 +432,7 @@ namespace cds { namespace intrusive { if ( pHead == nullptr ) pHead = init_bucket( nBucket ); - assert( pHead->is_dummy() ); + assert( pHead->is_dummy()); return pHead; } @@ -468,7 +468,7 @@ namespace cds { namespace intrusive { size_t sz = m_nBucketCountLog2.load(memory_model::memory_order_relaxed); const size_t nBucketCount = static_cast(1) << sz; - if ( nBucketCount < m_Buckets.capacity() ) { + if ( nBucketCount < m_Buckets.capacity()) { // we may grow the bucket table const size_t nLoadFactor = m_Buckets.load_factor(); if ( nMaxCount < max_item_count( nBucketCount, nLoadFactor )) @@ -555,7 +555,7 @@ namespace cds { namespace intrusive { dummy_node_type * pHead = get_bucket( nHash ); assert( pHead != nullptr ); - if ( m_List.erase_at( pHead, sv, cmp ) ) { + if ( m_List.erase_at( pHead, sv, cmp )) { --m_ItemCounter; m_Stat.onEraseSuccess(); return true; @@ -572,7 +572,7 @@ namespace cds { namespace intrusive { dummy_node_type * pHead = get_bucket( nHash ); assert( pHead != nullptr ); - if ( m_List.extract_at( pHead, guard, sv, cmp ) ) { + if ( m_List.extract_at( pHead, guard, sv, cmp )) { --m_ItemCounter; m_Stat.onExtractSuccess(); return true; @@ -590,7 +590,7 @@ namespace cds { namespace intrusive { template bool extract_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less ) { - return extract_( guard, key, typename wrapped_ordered_list::template make_compare_from_less() ); + return extract_( guard, key, typename wrapped_ordered_list::template make_compare_from_less()); } //@endcond @@ -603,7 +603,7 @@ namespace cds { namespace intrusive { */ SplitListSet() : m_nBucketCountLog2(1) - , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()) ) + , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor())) { init(); } @@ -615,7 +615,7 @@ namespace cds { namespace intrusive { ) : m_Buckets( nItemCount, nLoadFactor ) , m_nBucketCountLog2(1) - , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()) ) + , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor())) { init(); } @@ -756,7 +756,7 @@ namespace cds { namespace intrusive { dummy_node_type * pHead = get_bucket( nHash ); assert( pHead != nullptr ); - if ( m_List.unlink_at( pHead, val ) ) { + if ( m_List.unlink_at( pHead, val )) { --m_ItemCounter; m_Stat.onEraseSuccess(); return true; @@ -781,7 +781,7 @@ namespace cds { namespace intrusive { template bool erase( Q const& key ) { - return erase_( key, key_comparator() ); + return erase_( key, key_comparator()); } /// Deletes the item from the set with comparing functor \p pred @@ -796,7 +796,7 @@ namespace cds { namespace intrusive { bool erase_with( const Q& key, Less pred ) { CDS_UNUSED( pred ); - return erase_( key, typename wrapped_ordered_list::template make_compare_from_less() ); + return erase_( key, typename wrapped_ordered_list::template make_compare_from_less()); } /// Deletes the item from the set @@ -957,7 +957,7 @@ namespace cds { namespace intrusive { template bool contains( Q const& key ) { - return find_( key, key_comparator() ); + return find_( key, key_comparator()); } //@cond template @@ -978,7 +978,7 @@ namespace cds { namespace intrusive { bool contains( Q const& key, Less pred ) { CDS_UNUSED( pred ); - return find_( key, typename wrapped_ordered_list::template make_compare_from_less() ); + return find_( key, typename wrapped_ordered_list::template make_compare_from_less()); } //@cond template @@ -1069,7 +1069,7 @@ namespace cds { namespace intrusive { void clear() { iterator it = begin(); - while ( it != end() ) { + while ( it != end()) { iterator i(it); ++i; unlink( *it ); @@ -1132,7 +1132,7 @@ namespace cds { namespace intrusive { */ iterator begin() { - return iterator( m_List.begin(), m_List.end() ); + return iterator( m_List.begin(), m_List.end()); } /// Returns an iterator that addresses the location succeeding the last element in a split-list @@ -1144,7 +1144,7 @@ namespace cds { namespace intrusive { */ iterator end() { - return iterator( m_List.end(), m_List.end() ); + return iterator( m_List.end(), m_List.end()); } /// Returns a forward const iterator addressing the first element in a split-list @@ -1155,7 +1155,7 @@ namespace cds { namespace intrusive { /// Returns a forward const iterator addressing the first element in a split-list const_iterator cbegin() const { - return const_iterator( m_List.cbegin(), m_List.cend() ); + return const_iterator( m_List.cbegin(), m_List.cend()); } /// Returns an const iterator that addresses the location succeeding the last element in a split-list @@ -1166,7 +1166,7 @@ namespace cds { namespace intrusive { /// Returns an const iterator that addresses the location succeeding the last element in a split-list const_iterator cend() const { - return const_iterator( m_List.cend(), m_List.cend() ); + return const_iterator( m_List.cend(), m_List.cend()); } }; diff --git a/tests/unit/map2/map_delodd.cpp b/tests/unit/map2/map_delodd.cpp index 2642b099..e50c451b 100644 --- a/tests/unit/map2/map_delodd.cpp +++ b/tests/unit/map2/map_delodd.cpp @@ -33,8 +33,8 @@ namespace map2 { m_arrInsert[i] = i; m_arrRemove[i] = i; } - shuffle( m_arrInsert.begin(), m_arrInsert.end() ); - shuffle( m_arrRemove.begin(), m_arrRemove.end() ); + shuffle( m_arrInsert.begin(), m_arrInsert.end()); + shuffle( m_arrRemove.begin(), m_arrRemove.end()); } void Map_DelOdd::endTestCase() diff --git a/tests/unit/map2/map_delodd.h b/tests/unit/map2/map_delodd.h index 5d7992fe..883d6f8c 100644 --- a/tests/unit/map2/map_delodd.h +++ b/tests/unit/map2/map_delodd.h @@ -321,7 +321,7 @@ namespace map2 { } } else { - if ( eraser::erase(rMap, arrData[i], 0) ) + if ( eraser::erase(rMap, arrData[i], 0)) ++m_nDeleteSuccess; else ++m_nDeleteFailed; @@ -602,7 +602,7 @@ namespace map2 { pool.add( new insert_thread( pool, testMap ), c_nInsThreadCount ); pool.add( new delete_thread( pool, testMap ), c_nDelThreadCount ? c_nDelThreadCount : cds::OS::topology::processor_count()); pool.run(); - CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); + CPPUNIT_MSG( " Duration=" << pool.avgDuration()); size_t nInsertSuccess = 0; size_t nInsertFailed = 0; @@ -647,7 +647,7 @@ namespace map2 { if ( c_nExtractThreadCount ) pool.add( new extract_thread( pool, testMap ), c_nExtractThreadCount ); pool.run(); - CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); + CPPUNIT_MSG( " Duration=" << pool.avgDuration()); size_t nInsertSuccess = 0; size_t nInsertFailed = 0; @@ -698,7 +698,7 @@ namespace map2 { CPPUNIT_MSG( " Check even keys..." ); for ( size_t n = 0; n < c_nMapSize; n +=2 ) { for ( size_t i = 0; i < c_nInsThreadCount; ++i ) { - if ( !testMap.contains( key_type(n, i) ) ) { + if ( !testMap.contains( key_type(n, i))) { if ( ++nErrorCount < 10 ) { CPPUNIT_MSG( "key " << n << "-" << i << " is not found!"); } @@ -715,8 +715,8 @@ namespace map2 { CPPUNIT_MSG( " Clear map (single-threaded)..." ); timer.reset(); testMap.clear(); - CPPUNIT_MSG( " Duration=" << timer.duration() ); - CPPUNIT_CHECK_EX( testMap.empty(), ((long long) testMap.size()) ); + CPPUNIT_MSG( " Duration=" << timer.duration()); + CPPUNIT_CHECK_EX( testMap.empty(), ((long long) testMap.size())); additional_check( testMap ); print_stat( testMap ); diff --git a/tests/unit/map2/map_insdel_func.h b/tests/unit/map2/map_insdel_func.h index 78fa6bb7..d6dd3d5f 100644 --- a/tests/unit/map2/map_insdel_func.h +++ b/tests/unit/map2/map_insdel_func.h @@ -49,15 +49,15 @@ namespace map2 { , nData(0) , nUpdateCall(0) , bInitialized( false ) - , threadId( cds::OS::get_current_thread_id() ) + , threadId( cds::OS::get_current_thread_id()) {} value_type( value_type const& s ) : nKey(s.nKey) , nData(s.nData) , nUpdateCall(s.nUpdateCall.load(atomics::memory_order_relaxed)) - , bInitialized( s.bInitialized.load(atomics::memory_order_relaxed) ) - , threadId( cds::OS::get_current_thread_id() ) + , bInitialized( s.bInitialized.load(atomics::memory_order_relaxed)) + , threadId( cds::OS::get_current_thread_id()) {} // boost::container::flat_map requires operator = @@ -151,7 +151,7 @@ namespace map2 { if ( m_nThreadNo & 1 ) { for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) { - if ( rMap.insert_with( *it, std::ref(func) ) ) + if ( rMap.insert_with( *it, std::ref(func))) ++m_nInsertSuccess; else ++m_nInsertFailed; @@ -161,7 +161,7 @@ namespace map2 { else { for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) { - if ( rMap.insert_with( *it, std::ref(func) ) ) + if ( rMap.insert_with( *it, std::ref(func))) ++m_nInsertSuccess; else ++m_nInsertFailed; @@ -195,7 +195,7 @@ namespace map2 { template void operator()( bool bNew, Key const& key, Val& v ) { - std::unique_lock ac( v.m_access ); + std::unique_lock ac( v.m_access ); if ( bNew ) { ++nCreated; v.nKey = key; @@ -266,8 +266,7 @@ namespace map2 { if ( m_nThreadNo & 1 ) { for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) { - //for ( size_t nItem = 0; nItem < c_nMapSize; ++nItem ) { - std::pair ret = rMap.update( *it, std::ref( func ) ); + std::pair ret = rMap.update( *it, std::ref( func )); if ( ret.first ) { if ( ret.second ) ++m_nUpdateCreated; @@ -282,7 +281,7 @@ namespace map2 { else { for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) { - std::pair ret = rMap.update( *it, std::ref( func ) ); + std::pair ret = rMap.update( *it, std::ref( func )); if ( ret.first ) { if ( ret.second ) ++m_nUpdateCreated; @@ -394,7 +393,7 @@ namespace map2 { for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) { func.m_cnt.nKeyExpected = *it; - if ( rMap.erase( *it, std::ref(func) )) + if ( rMap.erase( *it, std::ref(func))) ++m_nDeleteSuccess; else ++m_nDeleteFailed; @@ -405,7 +404,7 @@ namespace map2 { for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) { for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) { func.m_cnt.nKeyExpected = *it; - if ( rMap.erase( *it, std::ref(func) )) + if ( rMap.erase( *it, std::ref(func))) ++m_nDeleteSuccess; else ++m_nDeleteFailed; @@ -432,14 +431,14 @@ namespace map2 { m_arrValues.reserve( c_nMapSize ); for ( size_t i = 0; i < c_nMapSize; ++i ) m_arrValues.push_back( i ); - shuffle( m_arrValues.begin(), m_arrValues.end() ); + shuffle( m_arrValues.begin(), m_arrValues.end()); CppUnitMini::ThreadPool pool( *this ); pool.add( new InserterThread( pool, testMap ), c_nInsertThreadCount ); pool.add( new DeleterThread( pool, testMap ), c_nDeleteThreadCount ); pool.add( new UpdaterThread( pool, testMap ), c_nUpdateThreadCount ); pool.run(); - CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); + CPPUNIT_MSG( " Duration=" << pool.avgDuration()); size_t nInsertSuccess = 0; size_t nInsertFailed = 0; @@ -507,8 +506,8 @@ namespace map2 { for ( size_t nItem = 0; nItem < c_nMapSize; ++nItem ) { testMap.erase( nItem ); } - CPPUNIT_MSG( " Duration=" << timer.duration() ); - CPPUNIT_CHECK( testMap.empty() ); + CPPUNIT_MSG( " Duration=" << timer.duration()); + CPPUNIT_CHECK( testMap.empty()); additional_check( testMap ); print_stat( testMap );