+
+ private:
+ //@cond
+ bool insert_at_locked( node_type * pHead, value_type& val )
+ {
+ // RCU lock should be locked!!!
+ assert( gc::is_locked() );
+
+ link_checker::is_empty( node_traits::to_node_ptr( val ));
+ position pos;
+ key_comparator cmp;
+
+ while ( true ) {
+ search( pHead, val, pos );
+ {
+ scoped_position_lock alp( pos );
+ 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;
+ }
+
+ link_node( node_traits::to_node_ptr( val ), pos.pPred, pos.pCur );
+ ++m_ItemCounter;
+ return true;
+ }
+ }
+ }
+ }
+
+ 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() );
+
+ position pos;
+ key_comparator cmp;
+
+ while ( true ) {
+ search( pHead, val, pos );
+ {
+ scoped_position_lock alp( pos );
+ 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
+
+ func( false, *node_traits::to_value_ptr( *pos.pCur ), val );
+ return std::make_pair( iterator( pos.pCur ), false );
+ }
+ else {
+ // new key
+ if ( !bAllowInsert )
+ return std::make_pair( end(), false );
+
+ 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 );
+ ++m_ItemCounter;
+ return std::make_pair( iterator( node_traits::to_node_ptr( val ) ), true );
+ }
+ }
+ }
+ }
+ }
+ //@endcond