Reformatting
authorkhizmax <libcds.dev@gmail.com>
Tue, 5 Jan 2016 06:28:27 +0000 (09:28 +0300)
committerkhizmax <libcds.dev@gmail.com>
Tue, 5 Jan 2016 06:28:27 +0000 (09:28 +0300)
cds/intrusive/impl/lazy_list.h
cds/intrusive/lazy_list_rcu.h
cds/intrusive/split_list_rcu.h
cds/urcu/details/gp.h
cds/urcu/details/gpi.h

index 412dca82ffa6d0ec02591c042a94605612ada9ca..58dcf5955eb3aa188d8af34de4d57eb8240e181e 100644 (file)
@@ -206,7 +206,7 @@ namespace cds { namespace intrusive {
         struct clean_disposer {
             void operator()( value_type * p )
             {
         struct clean_disposer {
             void operator()( value_type * p )
             {
-                lazy_list::node_cleaner<gc, node_type, memory_model>()( node_traits::to_node_ptr( p ) );
+                lazy_list::node_cleaner<gc, node_type, memory_model>()( node_traits::to_node_ptr( p ));
                 disposer()( p );
             }
         };
                 disposer()( p );
             }
         };
@@ -263,7 +263,7 @@ namespace cds { namespace intrusive {
         void retire_node( node_type * pNode )
         {
             assert( pNode != nullptr );
         void retire_node( node_type * pNode )
         {
             assert( pNode != nullptr );
-            gc::template retire<clean_disposer>( node_traits::to_value_ptr( *pNode ) );
+            gc::template retire<clean_disposer>( node_traits::to_value_ptr( *pNode ));
         }
         //@endcond
 
         }
         //@endcond
 
@@ -290,9 +290,9 @@ namespace cds { namespace intrusive {
                         do {
                             pNext = pCur->m_pNext.load(memory_model::memory_order_relaxed).ptr();
                             g.assign( node_traits::to_value_ptr( pNext ));
                         do {
                             pNext = pCur->m_pNext.load(memory_model::memory_order_relaxed).ptr();
                             g.assign( node_traits::to_value_ptr( pNext ));
-                        } while ( pNext != pCur->m_pNext.load(memory_model::memory_order_relaxed).ptr() );
+                        } while ( pNext != pCur->m_pNext.load(memory_model::memory_order_relaxed).ptr());
 
 
-                        m_pNode = m_Guard.assign( g.template get<value_type>() );
+                        m_pNode = m_Guard.assign( g.template get<value_type>());
                     }
                 }
             }
                     }
                 }
             }
@@ -304,14 +304,14 @@ namespace cds { namespace intrusive {
                     node_type * pNode = node_traits::to_node_ptr( m_pNode );
 
                     // Dummy tail node could not be marked
                     node_type * pNode = node_traits::to_node_ptr( m_pNode );
 
                     // Dummy tail node could not be marked
-                    while ( pNode->is_marked() ) {
+                    while ( pNode->is_marked()) {
                         node_type * p = pNode->m_pNext.load(memory_model::memory_order_relaxed).ptr();
                         g.assign( node_traits::to_value_ptr( p ));
                         node_type * p = pNode->m_pNext.load(memory_model::memory_order_relaxed).ptr();
                         g.assign( node_traits::to_value_ptr( p ));
-                        if ( p == pNode->m_pNext.load(memory_model::memory_order_relaxed).ptr() )
+                        if ( p == pNode->m_pNext.load(memory_model::memory_order_relaxed).ptr())
                             pNode = p;
                     }
                             pNode = p;
                     }
-                    if ( pNode != node_traits::to_node_ptr( m_pNode ) )
-                        m_pNode = m_Guard.assign( g.template get<value_type>() );
+                    if ( pNode != node_traits::to_node_ptr( m_pNode ))
+                        m_pNode = m_Guard.assign( g.template get<value_type>());
                 }
             }
 
                 }
             }
 
@@ -456,7 +456,7 @@ namespace cds { namespace intrusive {
         }
         const_iterator get_const_end() const
         {
         }
         const_iterator get_const_end() const
         {
-            return const_iterator( const_cast<node_type *>(&m_Tail) );
+            return const_iterator( const_cast<node_type *>(&m_Tail));
         }
         //@endcond
 
         }
         //@endcond
 
@@ -582,7 +582,7 @@ namespace cds { namespace intrusive {
         template <typename Q>
         bool erase( Q const& key )
         {
         template <typename Q>
         bool erase( Q const& key )
         {
-            return erase_at( &m_Head, key, key_comparator() );
+            return erase_at( &m_Head, key, key_comparator());
         }
 
         /// Deletes the item from the list using \p pred predicate for searching
         }
 
         /// Deletes the item from the list using \p pred predicate for searching
@@ -596,7 +596,7 @@ namespace cds { namespace intrusive {
         bool erase_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
         bool erase_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>() );
+            return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>());
         }
 
         /// Deletes the item from the list
         }
 
         /// Deletes the item from the list
@@ -663,7 +663,7 @@ namespace cds { namespace intrusive {
         guarded_ptr extract( Q const& key )
         {
             guarded_ptr gp;
         guarded_ptr extract( Q const& key )
         {
             guarded_ptr gp;
-            extract_at( &m_Head, gp.guard(), key, key_comparator() );
+            extract_at( &m_Head, gp.guard(), key, key_comparator());
             return gp;
         }
 
             return gp;
         }
 
@@ -681,7 +681,7 @@ namespace cds { namespace intrusive {
         {
             CDS_UNUSED( pred );
             guarded_ptr gp;
         {
             CDS_UNUSED( pred );
             guarded_ptr gp;
-            extract_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            extract_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>());
             return gp;
         }
 
             return gp;
         }
 
@@ -744,7 +744,7 @@ namespace cds { namespace intrusive {
         template <typename Q>
         bool contains( Q const& key )
         {
         template <typename Q>
         bool contains( Q const& key )
         {
-            return find_at( &m_Head, key, key_comparator() );
+            return find_at( &m_Head, key, key_comparator());
         }
         //@cond
         template <typename Q>
         }
         //@cond
         template <typename Q>
@@ -765,7 +765,7 @@ namespace cds { namespace intrusive {
         bool contains( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
         bool contains( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>() );
+            return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>());
         }
         //@cond
         template <typename Q, typename Less>
         }
         //@cond
         template <typename Q, typename Less>
@@ -809,7 +809,7 @@ namespace cds { namespace intrusive {
         guarded_ptr get( Q const& key )
         {
             guarded_ptr gp;
         guarded_ptr get( Q const& key )
         {
             guarded_ptr gp;
-            get_at( &m_Head, gp.guard(), key, key_comparator() );
+            get_at( &m_Head, gp.guard(), key, key_comparator());
             return gp;
         }
 
             return gp;
         }
 
@@ -827,7 +827,7 @@ namespace cds { namespace intrusive {
         {
             CDS_UNUSED( pred );
             guarded_ptr gp;
         {
             CDS_UNUSED( pred );
             guarded_ptr gp;
-            get_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            get_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>());
             return gp;
         }
 
             return gp;
         }
 
@@ -836,9 +836,9 @@ namespace cds { namespace intrusive {
         {
             typename gc::Guard guard;
             marked_node_ptr h;
         {
             typename gc::Guard guard;
             marked_node_ptr h;
-            while ( !empty() ) {
+            while ( !empty()) {
                 h = m_Head.m_pNext.load( memory_model::memory_order_relaxed );
                 h = m_Head.m_pNext.load( memory_model::memory_order_relaxed );
-                guard.assign( node_traits::to_value_ptr( h.ptr() ));
+                guard.assign( node_traits::to_value_ptr( h.ptr()));
                 if ( m_Head.m_pNext.load(memory_model::memory_order_acquire) == h ) {
                     m_Head.m_Lock.lock();
                     h->m_Lock.lock();
                 if ( m_Head.m_pNext.load(memory_model::memory_order_acquire) == h ) {
                     m_Head.m_Lock.lock();
                     h->m_Lock.lock();
@@ -848,7 +848,7 @@ namespace cds { namespace intrusive {
                     h->m_Lock.unlock();
                     m_Head.m_Lock.unlock();
 
                     h->m_Lock.unlock();
                     m_Head.m_Lock.unlock();
 
-                    retire_node( h.ptr() ) ; // free node
+                    retire_node( h.ptr()) ; // free node
                 }
             }
         }
                 }
             }
         }
@@ -888,17 +888,17 @@ namespace cds { namespace intrusive {
             // Hack: convert node_type to value_type.
             // In principle, auxiliary node cannot be reducible to value_type
             // We assume that internal comparator can correctly distinguish aux and regular node.
             // Hack: convert node_type to value_type.
             // In principle, auxiliary node cannot be reducible to value_type
             // We assume that internal comparator can correctly distinguish aux and regular node.
-            return insert_at( pHead, *node_traits::to_value_ptr( pNode ) );
+            return insert_at( pHead, *node_traits::to_value_ptr( pNode ));
         }
 
         bool insert_at( node_type * pHead, value_type& val )
         {
         }
 
         bool insert_at( node_type * pHead, value_type& val )
         {
-            link_checker::is_empty( node_traits::to_node_ptr( val ) );
+            link_checker::is_empty( node_traits::to_node_ptr( val ));
             position pos;
             key_comparator  cmp;
 
             while ( true ) {
             position pos;
             key_comparator  cmp;
 
             while ( true ) {
-                search( pHead, val, pos, key_comparator() );
+                search( pHead, val, pos, key_comparator());
                 {
                     scoped_position_lock alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
                 {
                     scoped_position_lock alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
@@ -919,12 +919,12 @@ namespace cds { namespace intrusive {
         template <typename Func>
         bool insert_at( node_type * pHead, value_type& val, Func f )
         {
         template <typename Func>
         bool insert_at( node_type * pHead, value_type& val, Func f )
         {
-            link_checker::is_empty( node_traits::to_node_ptr( val ) );
+            link_checker::is_empty( node_traits::to_node_ptr( val ));
             position pos;
             key_comparator  cmp;
 
             while ( true ) {
             position pos;
             key_comparator  cmp;
 
             while ( true ) {
-                search( pHead, val, pos, key_comparator() );
+                search( pHead, val, pos, key_comparator());
                 {
                     scoped_position_lock alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
                 {
                     scoped_position_lock alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
@@ -950,7 +950,7 @@ namespace cds { namespace intrusive {
             key_comparator  cmp;
 
             while ( true ) {
             key_comparator  cmp;
 
             while ( true ) {
-                search( pHead, val, pos, key_comparator() );
+                search( pHead, val, pos, key_comparator());
                 {
                     scoped_position_lock alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
                 {
                     scoped_position_lock alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
@@ -965,7 +965,7 @@ namespace cds { namespace intrusive {
                             if ( !bAllowInsert )
                                 return std::make_pair( false, false );
 
                             if ( !bAllowInsert )
                                 return std::make_pair( false, false );
 
-                            link_checker::is_empty( node_traits::to_node_ptr( val ) );
+                            link_checker::is_empty( node_traits::to_node_ptr( val ));
 
                             link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur );
                             func( true, val, val );
 
                             link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur );
                             func( true, val, val );
@@ -983,12 +983,12 @@ namespace cds { namespace intrusive {
             key_comparator  cmp;
 
             while ( true ) {
             key_comparator  cmp;
 
             while ( true ) {
-                search( pHead, val, pos, key_comparator() );
+                search( pHead, val, pos, key_comparator());
                 {
                     int nResult = 0;
                     {
                         scoped_position_lock alp( pos );
                 {
                     int nResult = 0;
                     {
                         scoped_position_lock alp( pos );
-                        if ( validate( pos.pPred, pos.pCur ) ) {
+                        if ( validate( pos.pPred, pos.pCur )) {
                             if ( pos.pCur != &m_Tail
                                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0
                                 && node_traits::to_value_ptr( pos.pCur ) == &val )
                             if ( pos.pCur != &m_Tail
                                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0
                                 && node_traits::to_value_ptr( pos.pCur ) == &val )
@@ -1026,7 +1026,7 @@ namespace cds { namespace intrusive {
                             if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                                 // key found
                                 unlink_node( pos.pPred, pos.pCur, pHead );
                             if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                                 // key found
                                 unlink_node( pos.pPred, pos.pCur, pHead );
-                                f( *node_traits::to_value_ptr( *pos.pCur ) );
+                                f( *node_traits::to_value_ptr( *pos.pCur ));
                                 --m_ItemCounter;
                                 nResult = 1;
                             }
                                 --m_ItemCounter;
                                 nResult = 1;
                             }
@@ -1065,7 +1065,7 @@ namespace cds { namespace intrusive {
         {
             position pos;
             if ( erase_at( pHead, val, cmp, [](value_type const &){}, pos )) {
         {
             position pos;
             if ( erase_at( pHead, val, cmp, [](value_type const &){}, pos )) {
-                gp.set( pos.guards.template get<value_type>(position::guard_current_item) );
+                gp.set( pos.guards.template get<value_type>(position::guard_current_item));
                 return true;
             }
             return false;
                 return true;
             }
             return false;
@@ -1130,7 +1130,7 @@ namespace cds { namespace intrusive {
 
             while ( pCur.ptr() != pTail ) {
                 if ( pCur.ptr() != pHead ) {
 
             while ( pCur.ptr() != pTail ) {
                 if ( pCur.ptr() != pHead ) {
-                    if ( cmp( *node_traits::to_value_ptr( *pCur.ptr() ), key ) >= 0 )
+                    if ( cmp( *node_traits::to_value_ptr( *pCur.ptr()), key ) >= 0 )
                         break;
                 }
 
                         break;
                 }
 
@@ -1141,8 +1141,8 @@ namespace cds { namespace intrusive {
                     []( marked_node_ptr p ) { return node_traits::to_value_ptr( p.ptr()); }
                 );
                 assert( pCur.ptr() != nullptr );
                     []( marked_node_ptr p ) { return node_traits::to_value_ptr( p.ptr()); }
                 );
                 assert( pCur.ptr() != nullptr );
-                if ( pCur->is_marked())
-                    pCur = pHead;
+                if ( pCur.bits())
+                    pPrev = pCur = pHead;
             }
 
             pos.pCur = pCur.ptr();
             }
 
             pos.pCur = pCur.ptr();
index 08409bb689cfa8dffb8693e19cf24914be67ff82..7d383f7566ee63dda25706b9c643c3efeb002f9a 100644 (file)
@@ -170,7 +170,7 @@ namespace cds { namespace intrusive {
 
         typedef std::unique_lock< position > scoped_position_lock;
 
 
         typedef std::unique_lock< position > scoped_position_lock;
 
-        typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock>   check_deadlock_policy;
+        typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock>   deadlock_policy;
         //@endcond
 
     protected:
         //@endcond
 
     protected:
@@ -192,16 +192,16 @@ namespace cds { namespace intrusive {
         static void dispose_node( node_type * pNode )
         {
             assert( pNode );
         static void dispose_node( node_type * pNode )
         {
             assert( pNode );
-            assert( !gc::is_locked() );
+            assert( !gc::is_locked());
 
 
-            gc::template retire_ptr<clear_and_dispose>( node_traits::to_value_ptr( *pNode ) );
+            gc::template retire_ptr<clear_and_dispose>( node_traits::to_value_ptr( *pNode ));
         }
 
         static void link_node( node_type * pNode, node_type * pPred, node_type * pCur )
         {
             assert( pPred->m_pNext.load(memory_model::memory_order_relaxed).ptr() == pCur );
 
         }
 
         static void link_node( node_type * pNode, node_type * pPred, node_type * pCur )
         {
             assert( pPred->m_pNext.load(memory_model::memory_order_relaxed).ptr() == pCur );
 
-            pNode->m_pNext.store( marked_node_ptr(pCur), memory_model::memory_order_release );
+            pNode->m_pNext.store( marked_node_ptr(pCur), memory_model::memory_order_relaxed );
             pPred->m_pNext.store( marked_node_ptr(pNode), memory_model::memory_order_release );
         }
 
             pPred->m_pNext.store( marked_node_ptr(pNode), memory_model::memory_order_release );
         }
 
@@ -211,7 +211,7 @@ namespace cds { namespace intrusive {
             assert( pCur != &m_Tail );
 
             node_type * pNext = pCur->m_pNext.load(memory_model::memory_order_relaxed).ptr();
             assert( pCur != &m_Tail );
 
             node_type * pNext = pCur->m_pNext.load(memory_model::memory_order_relaxed).ptr();
-            pCur->m_pNext.store( marked_node_ptr( pHead, 1 ), memory_model::memory_order_release ); // logical deletion + back-link for search
+            pCur->m_pNext.store( marked_node_ptr( pHead, 1 ), memory_model::memory_order_relaxed ); // logical deletion + back-link for search
             pPred->m_pNext.store( marked_node_ptr( pNext ), memory_model::memory_order_release); // physically deleting
         }
 
             pPred->m_pNext.store( marked_node_ptr( pNext ), memory_model::memory_order_release); // physically deleting
         }
 
@@ -249,10 +249,10 @@ namespace cds { namespace intrusive {
                     node_type * pNode = node_traits::to_node_ptr( m_pNode );
 
                     // Dummy tail node could not be marked
                     node_type * pNode = node_traits::to_node_ptr( m_pNode );
 
                     // Dummy tail node could not be marked
-                    while ( pNode->is_marked() )
+                    while ( pNode->is_marked())
                         pNode = pNode->m_pNext.load(memory_model::memory_order_acquire).ptr();
 
                         pNode = pNode->m_pNext.load(memory_model::memory_order_acquire).ptr();
 
-                    if ( pNode != node_traits::to_node_ptr( m_pNode ) )
+                    if ( pNode != node_traits::to_node_ptr( m_pNode ))
                         m_pNode = node_traits::to_value_ptr( pNode );
                 }
             }
                         m_pNode = node_traits::to_value_ptr( pNode );
                 }
             }
@@ -522,7 +522,7 @@ namespace cds { namespace intrusive {
         template <typename Q>
         bool erase( Q const& key )
         {
         template <typename Q>
         bool erase( Q const& key )
         {
-            return erase_at( &m_Head, key, key_comparator() );
+            return erase_at( &m_Head, key, key_comparator());
         }
 
         /// Deletes the item from the list using \p pred predicate for searching
         }
 
         /// Deletes the item from the list using \p pred predicate for searching
@@ -586,7 +586,7 @@ namespace cds { namespace intrusive {
             If the item is not found the function returns empty \p exempt_ptr.
 
             @note The function does NOT call RCU read-side lock or synchronization,
             If the item is not found the function returns empty \p exempt_ptr.
 
             @note The function does NOT call RCU read-side lock or synchronization,
-            and does NOT dispose the item found. It just excludes the item from the list
+            and does NOT dispose the item found. It just unlinks the item from the list
             and returns a pointer to it.
             You should manually lock RCU before calling this function, and you should manually synchronize RCU
             outside the RCU lock region before reusing returned pointer.
             and returns a pointer to it.
             You should manually lock RCU before calling this function, and you should manually synchronize RCU
             outside the RCU lock region before reusing returned pointer.
@@ -624,7 +624,7 @@ namespace cds { namespace intrusive {
         template <typename Q>
         exempt_ptr extract( Q const& key )
         {
         template <typename Q>
         exempt_ptr extract( Q const& key )
         {
-            return exempt_ptr( extract_at( &m_Head, key, key_comparator() ));
+            return exempt_ptr( extract_at( &m_Head, key, key_comparator()));
         }
 
         /// Extracts an item from the list using \p pred predicate for searching
         }
 
         /// Extracts an item from the list using \p pred predicate for searching
@@ -639,7 +639,7 @@ namespace cds { namespace intrusive {
         exempt_ptr extract_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
         exempt_ptr extract_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return exempt_ptr( extract_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>() ));
+            return exempt_ptr( extract_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>()));
         }
 
         /// Finds the key \p key
         }
 
         /// Finds the key \p key
@@ -701,7 +701,7 @@ namespace cds { namespace intrusive {
         template <typename Q>
         bool contains( Q const& key ) const
         {
         template <typename Q>
         bool contains( Q const& key ) const
         {
-            return find_at( const_cast<node_type *>( &m_Head ), key, key_comparator() );
+            return find_at( const_cast<node_type *>( &m_Head ), key, key_comparator());
         }
         //@cond
         template <typename Q>
         }
         //@cond
         template <typename Q>
@@ -722,7 +722,7 @@ namespace cds { namespace intrusive {
         bool contains( Q const& key, Less pred ) const
         {
             CDS_UNUSED( pred );
         bool contains( Q const& key, Less pred ) const
         {
             CDS_UNUSED( pred );
-            return find_at( const_cast<node_type *>( &m_Head ), key, cds::opt::details::make_comparator_from_less<Less>() );
+            return find_at( const_cast<node_type *>( &m_Head ), key, cds::opt::details::make_comparator_from_less<Less>());
         }
         //@cond
         template <typename Q, typename Less>
         }
         //@cond
         template <typename Q, typename Less>
@@ -748,7 +748,7 @@ namespace cds { namespace intrusive {
             // ...
             {
                 // Lock RCU
             // ...
             {
                 // Lock RCU
-                ord_list::rcu_lock lock;
+                typename ord_list::rcu_lock lock;
 
                 foo * pVal = theList.get( 5 );
                 if ( pVal ) {
 
                 foo * pVal = theList.get( 5 );
                 if ( pVal ) {
@@ -789,13 +789,13 @@ namespace cds { namespace intrusive {
             RCU \p synchronize method can be called.
             Note that depending on RCU type used the \ref disposer call can be deferred.
 
             RCU \p synchronize method can be called.
             Note that depending on RCU type used the \ref disposer call can be deferred.
 
-            The function can throw cds::urcu::rcu_deadlock exception if deadlock is encountered and
-            deadlock checking policy is opt::v::rcu_throw_deadlock.
+            The function can throw \p cds::urcu::rcu_deadlock exception if deadlock is encountered and
+            deadlock checking policy is \p opt::v::rcu_throw_deadlock.
         */
         void clear()
         {
         */
         void clear()
         {
-            if( !empty() ) {
-                check_deadlock_policy::check();
+            if( !empty()) {
+                deadlock_policy::check();
 
                 node_type * pHead;
                 for (;;) {
 
                 node_type * pHead;
                 for (;;) {
@@ -857,7 +857,7 @@ namespace cds { namespace intrusive {
             // Hack: convert node_type to value_type.
             // Actually, an auxiliary node should not be converted to value_type
             // We assume that comparator can correctly distinguish aux and regular node.
             // Hack: convert node_type to value_type.
             // Actually, an auxiliary node should not be converted to value_type
             // We assume that comparator can correctly distinguish aux and regular node.
-            return insert_at( pHead, *node_traits::to_value_ptr( pNode ) );
+            return insert_at( pHead, *node_traits::to_value_ptr( pNode ));
         }
 
         bool insert_at( node_type * pHead, value_type& val )
         }
 
         bool insert_at( node_type * pHead, value_type& val )
@@ -869,7 +869,7 @@ namespace cds { namespace intrusive {
         template <typename Func>
         bool insert_at( node_type * pHead, value_type& val, Func f )
         {
         template <typename Func>
         bool insert_at( node_type * pHead, value_type& val, Func f )
         {
-            link_checker::is_empty( node_traits::to_node_ptr( val ) );
+            link_checker::is_empty( node_traits::to_node_ptr( val ));
             position pos;
             key_comparator  cmp;
 
             position pos;
             key_comparator  cmp;
 
@@ -884,8 +884,8 @@ namespace cds { namespace intrusive {
                             return false;
                         }
 
                             return false;
                         }
 
-                        link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur );
                         f( val );
                         f( val );
+                        link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur );
                         ++m_ItemCounter;
                         return true;
                     }
                         ++m_ItemCounter;
                         return true;
                     }
@@ -921,7 +921,7 @@ namespace cds { namespace intrusive {
         {
             position pos;
             key_comparator  cmp;
         {
             position pos;
             key_comparator  cmp;
-            check_deadlock_policy::check();
+            deadlock_policy::check();
 
             while ( true ) {
                 int nResult = 0;
 
             while ( true ) {
                 int nResult = 0;
@@ -930,7 +930,7 @@ namespace cds { namespace intrusive {
                     search( pHead, val, pos );
                     {
                         scoped_position_lock alp( pos );
                     search( pHead, val, pos );
                     {
                         scoped_position_lock alp( pos );
-                        if ( validate( pos.pPred, pos.pCur ) ) {
+                        if ( validate( pos.pPred, pos.pCur )) {
                             if ( pos.pCur != &m_Tail
                                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0
                                 && node_traits::to_value_ptr( pos.pCur ) == &val )
                             if ( pos.pCur != &m_Tail
                                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0
                                 && node_traits::to_value_ptr( pos.pCur ) == &val )
@@ -959,7 +959,7 @@ namespace cds { namespace intrusive {
         template <typename Q, typename Compare, typename Func>
         bool erase_at( node_type * const pHead, Q const& val, Compare cmp, Func f, position& pos )
         {
         template <typename Q, typename Compare, typename Func>
         bool erase_at( node_type * const pHead, Q const& val, Compare cmp, Func f, position& pos )
         {
-            check_deadlock_policy::check();
+            deadlock_policy::check();
 
             while ( true ) {
                 int nResult = 0;
 
             while ( true ) {
                 int nResult = 0;
@@ -972,7 +972,7 @@ namespace cds { namespace intrusive {
                             if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                                 // key found
                                 unlink_node( pos.pPred, pos.pCur, pHead );
                             if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                                 // key found
                                 unlink_node( pos.pPred, pos.pCur, pHead );
-                                f( *node_traits::to_value_ptr( *pos.pCur ) );
+                                f( *node_traits::to_value_ptr( *pos.pCur ));
                                 --m_ItemCounter;
                                 nResult = 1;
                             }
                                 --m_ItemCounter;
                                 nResult = 1;
                             }
@@ -1010,7 +1010,7 @@ namespace cds { namespace intrusive {
         value_type * extract_at( node_type * const pHead, Q const& val, Compare cmp )
         {
             position pos;
         value_type * extract_at( node_type * const pHead, Q const& val, Compare cmp )
         {
             position pos;
-            assert( gc::is_locked() ) ; // RCU must be locked!!!
+            assert( gc::is_locked()) ; // RCU must be locked
 
             while ( true ) {
                 search( pHead, val, pos, cmp );
 
             while ( true ) {
                 search( pHead, val, pos, cmp );
@@ -1066,7 +1066,7 @@ namespace cds { namespace intrusive {
         template <typename Q, typename Compare>
         const_iterator find_at_( node_type * pHead, Q& val, Compare cmp ) const
         {
         template <typename Q, typename Compare>
         const_iterator find_at_( node_type * pHead, Q& val, Compare cmp ) const
         {
-            assert( gc::is_locked() );
+            assert( gc::is_locked());
 
             position pos;
 
 
             position pos;
 
@@ -1093,14 +1093,14 @@ namespace cds { namespace intrusive {
         template <typename Q>
         void search( node_type * const pHead, Q const& key, position& pos ) const
         {
         template <typename Q>
         void search( node_type * const pHead, Q const& key, position& pos ) const
         {
-            search( pHead, key, pos, key_comparator() );
+            search( pHead, key, pos, key_comparator());
         }
 
         template <typename Q, typename Compare>
         void search( node_type * const pHead, Q const& key, position& pos, Compare cmp ) const
         {
         }
 
         template <typename Q, typename Compare>
         void search( node_type * const pHead, Q const& key, position& pos, Compare cmp ) const
         {
-            // RCU should be locked!!!
-            assert( gc::is_locked() );
+            // RCU should be locked
+            assert( gc::is_locked());
 
             node_type const* pTail = &m_Tail;
 
 
             node_type const* pTail = &m_Tail;
 
@@ -1110,8 +1110,8 @@ namespace cds { namespace intrusive {
             while ( pCur != pTail && ( pCur == pHead || cmp( *node_traits::to_value_ptr( *pCur.ptr()), key ) < 0 )) {
                 pPrev = pCur;
                 pCur = pCur->m_pNext.load(memory_model::memory_order_acquire);
             while ( pCur != pTail && ( pCur == pHead || cmp( *node_traits::to_value_ptr( *pCur.ptr()), key ) < 0 )) {
                 pPrev = pCur;
                 pCur = pCur->m_pNext.load(memory_model::memory_order_acquire);
-                if ( pCur->is_marked())
-                    pCur = pHead;
+                if ( pCur.bits())
+                    pPrev = pCur = pHead;
             }
 
             pos.pCur = pCur.ptr();
             }
 
             pos.pCur = pCur.ptr();
@@ -1120,8 +1120,8 @@ namespace cds { namespace intrusive {
 
         static bool validate( node_type * pPred, node_type * pCur ) CDS_NOEXCEPT
         {
 
         static bool validate( node_type * pPred, node_type * pCur ) CDS_NOEXCEPT
         {
-            // RCU lock should be locked!!!
-            assert( gc::is_locked() );
+            // RCU lock should be locked
+            assert( gc::is_locked());
 
             return !pPred->is_marked()
                 && !pCur->is_marked()
 
             return !pPred->is_marked()
                 && !pCur->is_marked()
@@ -1134,8 +1134,8 @@ namespace cds { namespace intrusive {
         //@cond
         bool insert_at_locked( node_type * pHead, value_type& val )
         {
         //@cond
         bool insert_at_locked( node_type * pHead, value_type& val )
         {
-            // RCU lock should be locked!!!
-            assert( gc::is_locked() );
+            // RCU lock should be locked
+            assert( gc::is_locked());
 
             link_checker::is_empty( node_traits::to_node_ptr( val ));
             position pos;
 
             link_checker::is_empty( node_traits::to_node_ptr( val ));
             position pos;
@@ -1145,7 +1145,7 @@ namespace cds { namespace intrusive {
                 search( pHead, val, pos );
                 {
                     scoped_position_lock alp( pos );
                 search( pHead, val, pos );
                 {
                     scoped_position_lock alp( pos );
-                    if ( validate( pos.pPred, pos.pCur ) ) {
+                    if ( validate( pos.pPred, pos.pCur )) {
                         if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                             // failed: key already in list
                             return false;
                         if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                             // failed: key already in list
                             return false;
@@ -1162,8 +1162,8 @@ namespace cds { namespace intrusive {
         template <typename Func>
         std::pair<iterator, bool> update_at_locked( node_type * pHead, value_type& val, Func func, bool bAllowInsert )
         {
         template <typename Func>
         std::pair<iterator, bool> update_at_locked( node_type * pHead, value_type& val, Func func, bool bAllowInsert )
         {
-            // RCU lock should be locked!!!
-            assert( gc::is_locked() );
+            // RCU lock should be locked
+            assert( gc::is_locked());
 
             position pos;
             key_comparator  cmp;
 
             position pos;
             key_comparator  cmp;
@@ -1172,7 +1172,7 @@ namespace cds { namespace intrusive {
                 search( pHead, val, pos );
                 {
                     scoped_position_lock alp( pos );
                 search( pHead, val, pos );
                 {
                     scoped_position_lock alp( pos );
-                    if ( validate( pos.pPred, pos.pCur ) ) {
+                    if ( validate( pos.pPred, pos.pCur )) {
                         if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                             // key already in the list
 
                         if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                             // key already in the list
 
@@ -1184,12 +1184,12 @@ namespace cds { namespace intrusive {
                             if ( !bAllowInsert )
                                 return std::make_pair( end(), false );
 
                             if ( !bAllowInsert )
                                 return std::make_pair( end(), false );
 
-                            link_checker::is_empty( node_traits::to_node_ptr( val ) );
+                            link_checker::is_empty( node_traits::to_node_ptr( val ));
 
 
-                            link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur );
                             func( true, val, val );
                             func( true, val, val );
+                            link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur );
                             ++m_ItemCounter;
                             ++m_ItemCounter;
-                            return std::make_pair( iterator( node_traits::to_node_ptr( val ) ), true );
+                            return std::make_pair( iterator( node_traits::to_node_ptr( val )), true );
                         }
                     }
                 }
                         }
                     }
                 }
index 6d4061a9202f6ea70bbe3a385dfbc81ca5e6f9da..e106fc3579f454038944d4144d9bff1813a303cc 100644 (file)
@@ -125,7 +125,7 @@ namespace cds { namespace intrusive {
         class ordered_list_wrapper: public ordered_list
         {
             typedef ordered_list base_class;
         class ordered_list_wrapper: public ordered_list
         {
             typedef ordered_list base_class;
-            typedef typename base_class::auxiliary_head       bucket_head_type;
+            typedef typename base_class::auxiliary_head bucket_head_type;
 
         public:
             bool insert_at( dummy_node_type * pHead, value_type& val )
 
         public:
             bool insert_at( dummy_node_type * pHead, value_type& val )
index f17762b721d312a7de034ab2f2fe46c158fc7eb3..89a65784b579bd43782cb5ada4a54106e3a8dab2 100644 (file)
@@ -85,8 +85,8 @@ namespace cds { namespace urcu { namespace details {
         OS::ThreadId const nullThreadId = OS::c_NullThreadId;
         m_nGlobalControl.fetch_xor( general_purpose_rcu::c_nControlBit, atomics::memory_order_seq_cst );
 
         OS::ThreadId const nullThreadId = OS::c_NullThreadId;
         m_nGlobalControl.fetch_xor( general_purpose_rcu::c_nControlBit, atomics::memory_order_seq_cst );
 
-        for ( thread_record * pRec = m_ThreadList.head( atomics::memory_order_acquire); pRec; pRec = pRec->m_list.m_pNext ) {
-            while ( pRec->m_list.m_idOwner.load( atomics::memory_order_acquire) != nullThreadId && check_grace_period( pRec ) ) {
+        for ( thread_record * pRec = m_ThreadList.head( atomics::memory_order_acquire ); pRec; pRec = pRec->m_list.m_pNext ) {
+            while ( pRec->m_list.m_idOwner.load( atomics::memory_order_acquire ) != nullThreadId && check_grace_period( pRec ) ) {
                 bkoff();
                 CDS_COMPILER_RW_BARRIER;
             }
                 bkoff();
                 CDS_COMPILER_RW_BARRIER;
             }
index afca407bde99e8a457fdb153230ce0551fa50ff5..ba7b6a9390d2c469b1f140bf2153592506c720b8 100644 (file)
@@ -148,7 +148,7 @@ namespace cds { namespace urcu {
         /// Waits to finish a grace period
         void synchronize()
         {
         /// Waits to finish a grace period
         void synchronize()
         {
-            assert( !is_locked());
+            assert( !thread_gc::is_locked());
             std::unique_lock<lock_type> sl( m_Lock );
             flip_and_wait();
             flip_and_wait();
             std::unique_lock<lock_type> sl( m_Lock );
             flip_and_wait();
             flip_and_wait();