From: khizmax Date: Tue, 5 Jan 2016 06:28:27 +0000 (+0300) Subject: Reformatting X-Git-Tag: v2.1.0~3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=82867a2f916a0a7af596a65ad5629c6f455edab8;p=libcds.git Reformatting --- diff --git a/cds/intrusive/impl/lazy_list.h b/cds/intrusive/impl/lazy_list.h index 412dca82..58dcf595 100644 --- a/cds/intrusive/impl/lazy_list.h +++ b/cds/intrusive/impl/lazy_list.h @@ -206,7 +206,7 @@ namespace cds { namespace intrusive { struct clean_disposer { void operator()( value_type * p ) { - lazy_list::node_cleaner()( node_traits::to_node_ptr( p ) ); + lazy_list::node_cleaner()( node_traits::to_node_ptr( p )); disposer()( p ); } }; @@ -263,7 +263,7 @@ namespace cds { namespace intrusive { 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 )); } //@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 )); - } 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() ); + m_pNode = m_Guard.assign( g.template get()); } } } @@ -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 - 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 )); - 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; } - if ( pNode != node_traits::to_node_ptr( m_pNode ) ) - m_pNode = m_Guard.assign( g.template get() ); + if ( pNode != node_traits::to_node_ptr( m_pNode )) + m_pNode = m_Guard.assign( g.template get()); } } @@ -456,7 +456,7 @@ namespace cds { namespace intrusive { } const_iterator get_const_end() const { - return const_iterator( const_cast(&m_Tail) ); + return const_iterator( const_cast(&m_Tail)); } //@endcond @@ -582,7 +582,7 @@ namespace cds { namespace intrusive { template 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 @@ -596,7 +596,7 @@ namespace cds { namespace intrusive { bool erase_with( Q const& key, Less pred ) { CDS_UNUSED( pred ); - return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less() ); + return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less()); } /// Deletes the item from the list @@ -663,7 +663,7 @@ namespace cds { namespace intrusive { 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; } @@ -681,7 +681,7 @@ namespace cds { namespace intrusive { { CDS_UNUSED( pred ); guarded_ptr gp; - extract_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less() ); + extract_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less()); return gp; } @@ -744,7 +744,7 @@ namespace cds { namespace intrusive { template bool contains( Q const& key ) { - return find_at( &m_Head, key, key_comparator() ); + return find_at( &m_Head, key, key_comparator()); } //@cond template @@ -765,7 +765,7 @@ namespace cds { namespace intrusive { bool contains( Q const& key, Less pred ) { CDS_UNUSED( pred ); - return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less() ); + return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less()); } //@cond template @@ -809,7 +809,7 @@ namespace cds { namespace intrusive { 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; } @@ -827,7 +827,7 @@ namespace cds { namespace intrusive { { CDS_UNUSED( pred ); guarded_ptr gp; - get_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less() ); + get_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less()); return gp; } @@ -836,9 +836,9 @@ namespace cds { namespace intrusive { { typename gc::Guard guard; marked_node_ptr h; - while ( !empty() ) { + while ( !empty()) { 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(); @@ -848,7 +848,7 @@ namespace cds { namespace intrusive { 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. - 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 ) { - 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 ) { - search( pHead, val, pos, key_comparator() ); + search( pHead, val, pos, key_comparator()); { scoped_position_lock alp( pos ); if ( validate( pos.pPred, pos.pCur )) { @@ -919,12 +919,12 @@ namespace cds { namespace intrusive { template 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 ) { - search( pHead, val, pos, key_comparator() ); + search( pHead, val, pos, key_comparator()); { scoped_position_lock alp( pos ); if ( validate( pos.pPred, pos.pCur )) { @@ -950,7 +950,7 @@ namespace cds { namespace intrusive { 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 )) { @@ -965,7 +965,7 @@ namespace cds { namespace intrusive { 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 ); @@ -983,12 +983,12 @@ namespace cds { namespace intrusive { 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 ); - 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 ) @@ -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 ); - f( *node_traits::to_value_ptr( *pos.pCur ) ); + f( *node_traits::to_value_ptr( *pos.pCur )); --m_ItemCounter; nResult = 1; } @@ -1065,7 +1065,7 @@ namespace cds { namespace intrusive { { position pos; if ( erase_at( pHead, val, cmp, [](value_type const &){}, pos )) { - gp.set( pos.guards.template get(position::guard_current_item) ); + gp.set( pos.guards.template get(position::guard_current_item)); return true; } return false; @@ -1130,7 +1130,7 @@ namespace cds { namespace intrusive { 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; } @@ -1141,8 +1141,8 @@ namespace cds { namespace intrusive { []( 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(); diff --git a/cds/intrusive/lazy_list_rcu.h b/cds/intrusive/lazy_list_rcu.h index 08409bb6..7d383f75 100644 --- a/cds/intrusive/lazy_list_rcu.h +++ b/cds/intrusive/lazy_list_rcu.h @@ -170,7 +170,7 @@ namespace cds { namespace intrusive { 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: @@ -192,16 +192,16 @@ namespace cds { namespace intrusive { static void dispose_node( node_type * pNode ) { assert( pNode ); - assert( !gc::is_locked() ); + assert( !gc::is_locked()); - gc::template retire_ptr( node_traits::to_value_ptr( *pNode ) ); + gc::template retire_ptr( 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 ); - 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 ); } @@ -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(); - 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 } @@ -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 - while ( pNode->is_marked() ) + while ( pNode->is_marked()) 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 ); } } @@ -522,7 +522,7 @@ namespace cds { namespace intrusive { template 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 @@ -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, - 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. @@ -624,7 +624,7 @@ namespace cds { namespace intrusive { template 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 @@ -639,7 +639,7 @@ namespace cds { namespace intrusive { 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() )); + return exempt_ptr( extract_at( &m_Head, key, cds::opt::details::make_comparator_from_less())); } /// Finds the key \p key @@ -701,7 +701,7 @@ namespace cds { namespace intrusive { template bool contains( Q const& key ) const { - return find_at( const_cast( &m_Head ), key, key_comparator() ); + return find_at( const_cast( &m_Head ), key, key_comparator()); } //@cond template @@ -722,7 +722,7 @@ namespace cds { namespace intrusive { bool contains( Q const& key, Less pred ) const { CDS_UNUSED( pred ); - return find_at( const_cast( &m_Head ), key, cds::opt::details::make_comparator_from_less() ); + return find_at( const_cast( &m_Head ), key, cds::opt::details::make_comparator_from_less()); } //@cond template @@ -748,7 +748,7 @@ namespace cds { namespace intrusive { // ... { // Lock RCU - ord_list::rcu_lock lock; + typename ord_list::rcu_lock lock; 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. - 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() { - if( !empty() ) { - check_deadlock_policy::check(); + if( !empty()) { + deadlock_policy::check(); 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. - 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 ) @@ -869,7 +869,7 @@ namespace cds { namespace intrusive { template 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; @@ -884,8 +884,8 @@ namespace cds { namespace intrusive { return false; } - link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur ); f( val ); + link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur ); ++m_ItemCounter; return true; } @@ -921,7 +921,7 @@ namespace cds { namespace intrusive { { position pos; key_comparator cmp; - check_deadlock_policy::check(); + deadlock_policy::check(); while ( true ) { int nResult = 0; @@ -930,7 +930,7 @@ namespace cds { namespace intrusive { 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 ) @@ -959,7 +959,7 @@ namespace cds { namespace intrusive { template 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; @@ -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 ); - f( *node_traits::to_value_ptr( *pos.pCur ) ); + f( *node_traits::to_value_ptr( *pos.pCur )); --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; - assert( gc::is_locked() ) ; // RCU must be locked!!! + assert( gc::is_locked()) ; // RCU must be locked while ( true ) { search( pHead, val, pos, cmp ); @@ -1066,7 +1066,7 @@ namespace cds { namespace intrusive { template const_iterator find_at_( node_type * pHead, Q& val, Compare cmp ) const { - assert( gc::is_locked() ); + assert( gc::is_locked()); position pos; @@ -1093,14 +1093,14 @@ namespace cds { namespace intrusive { template 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 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; @@ -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); - if ( pCur->is_marked()) - pCur = pHead; + if ( pCur.bits()) + pPrev = pCur = pHead; } pos.pCur = pCur.ptr(); @@ -1120,8 +1120,8 @@ namespace cds { namespace intrusive { 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() @@ -1134,8 +1134,8 @@ namespace cds { namespace intrusive { //@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; @@ -1145,7 +1145,7 @@ namespace cds { namespace intrusive { 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; @@ -1162,8 +1162,8 @@ namespace cds { namespace intrusive { template std::pair 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; @@ -1172,7 +1172,7 @@ namespace cds { namespace intrusive { 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 @@ -1184,12 +1184,12 @@ namespace cds { namespace intrusive { 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 ); + link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur ); ++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 ); } } } diff --git a/cds/intrusive/split_list_rcu.h b/cds/intrusive/split_list_rcu.h index 6d4061a9..e106fc35 100644 --- a/cds/intrusive/split_list_rcu.h +++ b/cds/intrusive/split_list_rcu.h @@ -125,7 +125,7 @@ namespace cds { namespace intrusive { 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 ) diff --git a/cds/urcu/details/gp.h b/cds/urcu/details/gp.h index f17762b7..89a65784 100644 --- a/cds/urcu/details/gp.h +++ b/cds/urcu/details/gp.h @@ -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 ); - 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; } diff --git a/cds/urcu/details/gpi.h b/cds/urcu/details/gpi.h index afca407b..ba7b6a93 100644 --- a/cds/urcu/details/gpi.h +++ b/cds/urcu/details/gpi.h @@ -148,7 +148,7 @@ namespace cds { namespace urcu { /// Waits to finish a grace period void synchronize() { - assert( !is_locked()); + assert( !thread_gc::is_locked()); std::unique_lock sl( m_Lock ); flip_and_wait(); flip_and_wait();